使用本地值定义 Azure Databricks 用户块
Using Local values to define Azure Databricks User block
我想通过以下块授予两个用户使用 Azure Databricks 的权限:
resource "databricks_user" "dbuser" {
display_name = local.name.display_name
user_name = local.name.user_name
workspace_access = true
}
我将当地人定义如下:
locals {
name = {
display_name = ["Vincent Casinha",
"Susan Young"
]
user_name = ["vincent.casinha@contoso.com",
"susan.young@contoso.com"]
}
}
在尝试 运行 terraform 计划时,我收到了错误信息。我如何在 databricks_user 块中正确使用局部值作为参数 display_name & user_name?
locals {
display_name = ["Vincent Casinha", "Susan Young"]
user_name = ["vincent.casinha@contoso.com","susan.young@contoso.com"]
}
#assuming length of display_name and user_name are same
resource "databricks_user" "dbuser" {
count = length(local.display_name)
display_name = local.display_name[count.index]
user_name = local.user_name[count.index]
workspace_access = true
}
#或者你可以像下面那样做
locals {
name = [
{
display_name = "Vincent Casinha"
user_name = "vincent.casinha@contoso.com"
},
{
display_name = "Susan Young"
user_name = "susan.young@contoso.com"
}
]
}
resource "databricks_user" "dbuser" {
for_each = local.name
display_name = each.value.display_name
user_name = each.value.user_name
workspace_access = true
}
我想通过以下块授予两个用户使用 Azure Databricks 的权限:
resource "databricks_user" "dbuser" {
display_name = local.name.display_name
user_name = local.name.user_name
workspace_access = true
}
我将当地人定义如下:
locals {
name = {
display_name = ["Vincent Casinha",
"Susan Young"
]
user_name = ["vincent.casinha@contoso.com",
"susan.young@contoso.com"]
}
}
在尝试 运行 terraform
locals {
display_name = ["Vincent Casinha", "Susan Young"]
user_name = ["vincent.casinha@contoso.com","susan.young@contoso.com"]
}
#assuming length of display_name and user_name are same
resource "databricks_user" "dbuser" {
count = length(local.display_name)
display_name = local.display_name[count.index]
user_name = local.user_name[count.index]
workspace_access = true
}
#或者你可以像下面那样做
locals {
name = [
{
display_name = "Vincent Casinha"
user_name = "vincent.casinha@contoso.com"
},
{
display_name = "Susan Young"
user_name = "susan.young@contoso.com"
}
]
}
resource "databricks_user" "dbuser" {
for_each = local.name
display_name = each.value.display_name
user_name = each.value.user_name
workspace_access = true
}