1.0" azurerm-6ren">
gpt4 book ai didi

azure - Azure Databricks 和 Terraform 出现错误

转载 作者:行者123 更新时间:2023-12-03 07:03:18 28 4
gpt4 key购买 nike

我的 Databricks 有以下代码。目前我只有工作区,但工作区中没有集群

  required_providers {
azuread = "~> 1.0"
azurerm = "~> 2.0"
azuredevops = { source = "registry.terraform.io/microsoft/azuredevops", version = "~> 0.0" }
databricks = { source = "registry.terraform.io/databrickslabs/databricks", version = "~> 0.0" }
}
}

provider "random" {}
provider "azuread" {
tenant_id = var.project.arm.tenant.id
client_id = var.project.arm.client.id
client_secret = var.secret.arm.client.secret
}

provider "databricks" {
host = azurerm_databricks_workspace.db-workspace.workspace_url
azure_workspace_resource_id = azurerm_databricks_workspace.db-workspace.id
azure_tenant_id = var.project.arm.tenant.id
azure_client_id = var.project.arm.client.id
azure_client_secret = var.secret.arm.client.secret
}


resource "azurerm_databricks_workspace" "db-workspace" {
name = module.names-db-workspace.environment.databricks_workspace.name_unique
resource_group_name = module.resourcegroup.resource_group.name
location = module.resourcegroup.resource_group.location
sku = "premium"
public_network_access_enabled = true

custom_parameters {
no_public_ip = true
virtual_network_id = module.virtualnetwork["centralus"].virtual_network.self.id
public_subnet_name = module.virtualnetwork["centralus"].virtual_network.subnets["db-sub-1-public"].name
private_subnet_name = module.virtualnetwork["centralus"].virtual_network.subnets["db-sub-2-private"].name
public_subnet_network_security_group_association_id = module.virtualnetwork["centralus"].virtual_network.nsgs.associations.subnets["databricks-public-nsg-db-sub-1-public"].id
private_subnet_network_security_group_association_id = module.virtualnetwork["centralus"].virtual_network.nsgs.associations.subnets["databricks-private-nsg-db-sub-2-private"].id
}
tags = local.tags
}

Databricks 集群创建

resource "databricks_cluster" "dbcselfservice" {
cluster_name = format("adb-cluster-%s-%s", var.project.name, var.project.environment.name)
spark_version = var.spark_version
node_type_id = var.node_type_id
autotermination_minutes = 20
autoscale {
min_workers = 1
max_workers = 7
}
azure_attributes {
availability = "SPOT_AZURE"
first_on_demand = 1
spot_bid_max_price = 100
}
depends_on = [
azurerm_databricks_workspace.db-workspace
]
}

Databricks 工作区 RBAC 权限

resource "databricks_group" "db-group" {
display_name = format("adb-users-%s", var.project.name)
allow_cluster_create = true
allow_instance_pool_create = true
depends_on = [
resource.azurerm_databricks_workspace.db-workspace
]
}

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
depends_on = [
resource.azurerm_databricks_workspace.db-workspace
]
}

将成员添加到 Databricks 管理组

resource "databricks_group_member" "i-am-admin" {
for_each = toset(local.email_address)
group_id = data.databricks_group.admins.id
member_id = databricks_user.dbuser[index(local.email_address, each.key)].id
depends_on = [
resource.azurerm_databricks_workspace.db-workspace
]
}

data "databricks_group" "admins" {
display_name = "admins"
depends_on = [
# resource.databricks_cluster.dbcselfservice,
resource.azurerm_databricks_workspace.db-workspace
]
}

当我尝试运行 Terraform 计划时,出现以下错误:

Error: cannot read group: cannot configure azure-client-secret auth: cannot get workspace: please set `azure_workspace_resource_id` provider argument. Attributes used: azure_client_id, azure_client_secret, azure_tenant_id. Please check https://registry.terraform.io/providers/databrickslabs/databricks/latest/docs#authentication for details

│ with databricks_group.db-group,
│ on resources.adb.tf line 71, in resource "databricks_group" "db-group":
│ 71: resource "databricks_group" "db-group" {



│ Error: cannot read user: cannot configure azure-client-secret auth: cannot get workspace: please set `azure_workspace_resource_id` provider argument. Attributes used: azure_client_id, azure_client_secret, azure_tenant_id. Please check https://registry.terraform.io/providers/databrickslabs/databricks/latest/docs#authentication for details

│ with databricks_user.dbuser[0],
│ on resources.adb.tf line 80, in resource "databricks_user" "dbuser":
│ 80: resource "databricks_user" "dbuser" {

但是如果我在资源 block “azurerm_databricks_workspace”中注释掉“custom_parameters”,我就看不到该错误。在Azure中,我只有Databricks工作区,没有集群,我想创建集群并计划第二次运行Terraform

几周前,我删除并重新创建了我的子网。现在我的子网有了新名称

现在,如果我注释掉 custom_parameters,Terraform Apply 在创建集群时会抛出错误,并表示无法找到旧子网。但是我的子网引用位于 custom_parameters 中,我必须将其注释掉。

所以我现在处于第 22 条军规的情况。知道如何解决这个问题

最佳答案

您的代码中有一些更改,请按照下面的建议进行更改。

db-groupdbuseri-am- 的依赖项中使用 azurerm_databricks_workspace.db-workspace adminadmins 而不是 resource.azurerm_databricks_workspace.db-workspace

正如本Github中所建议的那样讨论尝试使用 Azurerm 提供程序版本 2.78,作为目前的解决方法,请首先应用工作区创建,然后应用其中的资源。

关于azure - Azure Databricks 和 Terraform 出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71928803/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com