Change databricks workspace groups into account groups

I had a Databricks workspace that was not Unity Catalog enabled. So I had to create in terraform databricks groups in workspace level.

Now my Workspace has UC, I can create account groups from the interface. But I can not manage to make it work with terraform.

The documentation says that we need to add a provider databricks with host https://accounts.azuredatabricks.net/.

Originally this is my tf code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># Used to create clusters/sql warehouses and policies in the workspace
provider "databricks" {
azure_workspace_resource_id = module.databricks_01.id
azure_client_id = local.service_principal_application_id
azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET
azure_tenant_id = var.secrets.TENANT_ID
}
# this is inside a module, providers are defined at root of project, not in sub modules
resource "databricks_group" "this" {
for_each = data.azuread_group.this
display_name = each.key
external_id = data.azuread_group.this[each.key].object_id
workspace_access = var.groups[each.key].workspace_access
databricks_sql_access = var.groups[each.key].databricks_sql_access
allow_cluster_create = var.groups[each.key].allow_cluster_create
allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create
force = false
}
</code>
<code># Used to create clusters/sql warehouses and policies in the workspace provider "databricks" { azure_workspace_resource_id = module.databricks_01.id azure_client_id = local.service_principal_application_id azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET azure_tenant_id = var.secrets.TENANT_ID } # this is inside a module, providers are defined at root of project, not in sub modules resource "databricks_group" "this" { for_each = data.azuread_group.this display_name = each.key external_id = data.azuread_group.this[each.key].object_id workspace_access = var.groups[each.key].workspace_access databricks_sql_access = var.groups[each.key].databricks_sql_access allow_cluster_create = var.groups[each.key].allow_cluster_create allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create force = false } </code>
# Used to create clusters/sql warehouses and policies in the workspace
provider "databricks" {
  azure_workspace_resource_id = module.databricks_01.id
  azure_client_id             = local.service_principal_application_id
  azure_client_secret         = var.secrets.SERVICE_PRINCIPAL_SECRET
  azure_tenant_id             = var.secrets.TENANT_ID
}

# this is inside a module, providers are defined at root of project, not in sub modules
resource "databricks_group" "this" {
  for_each                   = data.azuread_group.this
  display_name               = each.key
  external_id                = data.azuread_group.this[each.key].object_id
  workspace_access           = var.groups[each.key].workspace_access
  databricks_sql_access      = var.groups[each.key].databricks_sql_access
  allow_cluster_create       = var.groups[each.key].allow_cluster_create
  allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create
  force                      = false
}

This is what I tried:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># Used to create clusters/sql warehouses and policies in the workspace
provider "databricks" {
azure_workspace_resource_id = module.databricks_01.id
azure_client_id = local.service_principal_application_id
azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET
azure_tenant_id = var.secrets.TENANT_ID
}
provider "databricks" {
alias = "accounts"
host = "https://accounts.azuredatabricks.net"
account_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # My personal account ID from https://accounts.azuredatabricks.net/ at top right "My Account"
azure_client_id = local.service_principal_application_id
azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET
azure_tenant_id = var.secrets.TENANT_ID
}
# this is inside a module, providers are defined at root of project, not in sub modules
resource "databricks_group" "this" {
provider = databricks.accounts
for_each = data.azuread_group.this
display_name = each.key
external_id = data.azuread_group.this[each.key].object_id
workspace_access = var.groups[each.key].workspace_access
databricks_sql_access = var.groups[each.key].databricks_sql_access
allow_cluster_create = var.groups[each.key].allow_cluster_create
allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create
force = false
}
</code>
<code># Used to create clusters/sql warehouses and policies in the workspace provider "databricks" { azure_workspace_resource_id = module.databricks_01.id azure_client_id = local.service_principal_application_id azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET azure_tenant_id = var.secrets.TENANT_ID } provider "databricks" { alias = "accounts" host = "https://accounts.azuredatabricks.net" account_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # My personal account ID from https://accounts.azuredatabricks.net/ at top right "My Account" azure_client_id = local.service_principal_application_id azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET azure_tenant_id = var.secrets.TENANT_ID } # this is inside a module, providers are defined at root of project, not in sub modules resource "databricks_group" "this" { provider = databricks.accounts for_each = data.azuread_group.this display_name = each.key external_id = data.azuread_group.this[each.key].object_id workspace_access = var.groups[each.key].workspace_access databricks_sql_access = var.groups[each.key].databricks_sql_access allow_cluster_create = var.groups[each.key].allow_cluster_create allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create force = false } </code>
# Used to create clusters/sql warehouses and policies in the workspace
provider "databricks" {
  azure_workspace_resource_id = module.databricks_01.id
  azure_client_id             = local.service_principal_application_id
  azure_client_secret         = var.secrets.SERVICE_PRINCIPAL_SECRET
  azure_tenant_id             = var.secrets.TENANT_ID
}
provider "databricks" {
  alias               = "accounts"
  host                = "https://accounts.azuredatabricks.net"
  account_id          = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # My personal account ID from https://accounts.azuredatabricks.net/ at top right "My Account"
  azure_client_id     = local.service_principal_application_id
  azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET
  azure_tenant_id     = var.secrets.TENANT_ID
}

# this is inside a module, providers are defined at root of project, not in sub modules
resource "databricks_group" "this" {
  provider                   = databricks.accounts
  for_each                   = data.azuread_group.this
  display_name               = each.key
  external_id                = data.azuread_group.this[each.key].object_id
  workspace_access           = var.groups[each.key].workspace_access
  databricks_sql_access      = var.groups[each.key].databricks_sql_access
  allow_cluster_create       = var.groups[each.key].allow_cluster_create
  allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create
  force                      = false
}

I’ve first removed databricks_group.this by commenting the code and made an apply. So all workspaces groups are removed.
Then uncommented my code and added the provider option to specify databricks.accounts

But I get this error that I don’t understand because the ressource is not in the state:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>> terraform apply -var-file=context_and_secrets.json -auto-approve
│ Error: Provider configuration not present
│ To work with module.databricks_policy.databricks_group.this its original provider configuration at
│ module.databricks_policy.provider["registry.terraform.io/databricks/databricks"].accounts is required, but it has been
│ removed. This occurs when a provider configuration is removed while objects created by that provider still exist in the
│ state. Re-add the provider configuration to destroy module.databricks_policy.databricks_group.this, after which you can
│ remove the provider configuration again.
</code>
<code>> terraform apply -var-file=context_and_secrets.json -auto-approve ╷ │ Error: Provider configuration not present │ │ To work with module.databricks_policy.databricks_group.this its original provider configuration at │ module.databricks_policy.provider["registry.terraform.io/databricks/databricks"].accounts is required, but it has been │ removed. This occurs when a provider configuration is removed while objects created by that provider still exist in the │ state. Re-add the provider configuration to destroy module.databricks_policy.databricks_group.this, after which you can │ remove the provider configuration again. </code>
> terraform apply -var-file=context_and_secrets.json -auto-approve
╷
│ Error: Provider configuration not present
│
│ To work with module.databricks_policy.databricks_group.this its original provider configuration at
│ module.databricks_policy.provider["registry.terraform.io/databricks/databricks"].accounts is required, but it has been   
│ removed. This occurs when a provider configuration is removed while objects created by that provider still exist in the  
│ state. Re-add the provider configuration to destroy module.databricks_policy.databricks_group.this, after which you can  
│ remove the provider configuration again.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Change databricks workspace groups into account groups

I had a Databricks workspace that was not Unity Catalog enabled. So I had to create in terraform databricks groups in workspace level.

Now my Workspace has UC, I can create account groups from the interface. But I can not manage to make it work with terraform.

The documentation says that we need to add a provider databricks with host https://accounts.azuredatabricks.net/.

Originally this is my tf code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># Used to create clusters/sql warehouses and policies in the workspace
provider "databricks" {
azure_workspace_resource_id = module.databricks_01.id
azure_client_id = local.service_principal_application_id
azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET
azure_tenant_id = var.secrets.TENANT_ID
}
# this is inside a module, providers are defined at root of project, not in sub modules
resource "databricks_group" "this" {
for_each = data.azuread_group.this
display_name = each.key
external_id = data.azuread_group.this[each.key].object_id
workspace_access = var.groups[each.key].workspace_access
databricks_sql_access = var.groups[each.key].databricks_sql_access
allow_cluster_create = var.groups[each.key].allow_cluster_create
allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create
force = false
}
</code>
<code># Used to create clusters/sql warehouses and policies in the workspace provider "databricks" { azure_workspace_resource_id = module.databricks_01.id azure_client_id = local.service_principal_application_id azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET azure_tenant_id = var.secrets.TENANT_ID } # this is inside a module, providers are defined at root of project, not in sub modules resource "databricks_group" "this" { for_each = data.azuread_group.this display_name = each.key external_id = data.azuread_group.this[each.key].object_id workspace_access = var.groups[each.key].workspace_access databricks_sql_access = var.groups[each.key].databricks_sql_access allow_cluster_create = var.groups[each.key].allow_cluster_create allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create force = false } </code>
# Used to create clusters/sql warehouses and policies in the workspace
provider "databricks" {
  azure_workspace_resource_id = module.databricks_01.id
  azure_client_id             = local.service_principal_application_id
  azure_client_secret         = var.secrets.SERVICE_PRINCIPAL_SECRET
  azure_tenant_id             = var.secrets.TENANT_ID
}

# this is inside a module, providers are defined at root of project, not in sub modules
resource "databricks_group" "this" {
  for_each                   = data.azuread_group.this
  display_name               = each.key
  external_id                = data.azuread_group.this[each.key].object_id
  workspace_access           = var.groups[each.key].workspace_access
  databricks_sql_access      = var.groups[each.key].databricks_sql_access
  allow_cluster_create       = var.groups[each.key].allow_cluster_create
  allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create
  force                      = false
}

This is what I tried:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># Used to create clusters/sql warehouses and policies in the workspace
provider "databricks" {
azure_workspace_resource_id = module.databricks_01.id
azure_client_id = local.service_principal_application_id
azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET
azure_tenant_id = var.secrets.TENANT_ID
}
provider "databricks" {
alias = "accounts"
host = "https://accounts.azuredatabricks.net"
account_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # My personal account ID from https://accounts.azuredatabricks.net/ at top right "My Account"
azure_client_id = local.service_principal_application_id
azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET
azure_tenant_id = var.secrets.TENANT_ID
}
# this is inside a module, providers are defined at root of project, not in sub modules
resource "databricks_group" "this" {
provider = databricks.accounts
for_each = data.azuread_group.this
display_name = each.key
external_id = data.azuread_group.this[each.key].object_id
workspace_access = var.groups[each.key].workspace_access
databricks_sql_access = var.groups[each.key].databricks_sql_access
allow_cluster_create = var.groups[each.key].allow_cluster_create
allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create
force = false
}
</code>
<code># Used to create clusters/sql warehouses and policies in the workspace provider "databricks" { azure_workspace_resource_id = module.databricks_01.id azure_client_id = local.service_principal_application_id azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET azure_tenant_id = var.secrets.TENANT_ID } provider "databricks" { alias = "accounts" host = "https://accounts.azuredatabricks.net" account_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # My personal account ID from https://accounts.azuredatabricks.net/ at top right "My Account" azure_client_id = local.service_principal_application_id azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET azure_tenant_id = var.secrets.TENANT_ID } # this is inside a module, providers are defined at root of project, not in sub modules resource "databricks_group" "this" { provider = databricks.accounts for_each = data.azuread_group.this display_name = each.key external_id = data.azuread_group.this[each.key].object_id workspace_access = var.groups[each.key].workspace_access databricks_sql_access = var.groups[each.key].databricks_sql_access allow_cluster_create = var.groups[each.key].allow_cluster_create allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create force = false } </code>
# Used to create clusters/sql warehouses and policies in the workspace
provider "databricks" {
  azure_workspace_resource_id = module.databricks_01.id
  azure_client_id             = local.service_principal_application_id
  azure_client_secret         = var.secrets.SERVICE_PRINCIPAL_SECRET
  azure_tenant_id             = var.secrets.TENANT_ID
}
provider "databricks" {
  alias               = "accounts"
  host                = "https://accounts.azuredatabricks.net"
  account_id          = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # My personal account ID from https://accounts.azuredatabricks.net/ at top right "My Account"
  azure_client_id     = local.service_principal_application_id
  azure_client_secret = var.secrets.SERVICE_PRINCIPAL_SECRET
  azure_tenant_id     = var.secrets.TENANT_ID
}

# this is inside a module, providers are defined at root of project, not in sub modules
resource "databricks_group" "this" {
  provider                   = databricks.accounts
  for_each                   = data.azuread_group.this
  display_name               = each.key
  external_id                = data.azuread_group.this[each.key].object_id
  workspace_access           = var.groups[each.key].workspace_access
  databricks_sql_access      = var.groups[each.key].databricks_sql_access
  allow_cluster_create       = var.groups[each.key].allow_cluster_create
  allow_instance_pool_create = var.groups[each.key].allow_instance_pool_create
  force                      = false
}

I’ve first removed databricks_group.this by commenting the code and made an apply. So all workspaces groups are removed.
Then uncommented my code and added the provider option to specify databricks.accounts

But I get this error that I don’t understand because the ressource is not in the state:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>> terraform apply -var-file=context_and_secrets.json -auto-approve
│ Error: Provider configuration not present
│ To work with module.databricks_policy.databricks_group.this its original provider configuration at
│ module.databricks_policy.provider["registry.terraform.io/databricks/databricks"].accounts is required, but it has been
│ removed. This occurs when a provider configuration is removed while objects created by that provider still exist in the
│ state. Re-add the provider configuration to destroy module.databricks_policy.databricks_group.this, after which you can
│ remove the provider configuration again.
</code>
<code>> terraform apply -var-file=context_and_secrets.json -auto-approve ╷ │ Error: Provider configuration not present │ │ To work with module.databricks_policy.databricks_group.this its original provider configuration at │ module.databricks_policy.provider["registry.terraform.io/databricks/databricks"].accounts is required, but it has been │ removed. This occurs when a provider configuration is removed while objects created by that provider still exist in the │ state. Re-add the provider configuration to destroy module.databricks_policy.databricks_group.this, after which you can │ remove the provider configuration again. </code>
> terraform apply -var-file=context_and_secrets.json -auto-approve
╷
│ Error: Provider configuration not present
│
│ To work with module.databricks_policy.databricks_group.this its original provider configuration at
│ module.databricks_policy.provider["registry.terraform.io/databricks/databricks"].accounts is required, but it has been   
│ removed. This occurs when a provider configuration is removed while objects created by that provider still exist in the  
│ state. Re-add the provider configuration to destroy module.databricks_policy.databricks_group.this, after which you can  
│ remove the provider configuration again.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật