databricks / terraform-provider-databricks

Databricks Terraform Provider
https://registry.terraform.io/providers/databricks/databricks/latest
Other
444 stars 384 forks source link

[ISSUE] Issue with `databricks_mws_permission_assignment ` resource for duplicate workspace user groups #1793

Closed vadivelselvaraj closed 1 year ago

vadivelselvaraj commented 1 year ago

when assigning account-level user groups to a workspace that has Identity Federation(IF) enabled and if the group already exists we get the below error. The error statement should be revised to say that "Account level user group already exists in the workspace. Please delete the existing group in the workspace to fix this".

Error

Error: cannot create mws permission assignment: Databricks API (/api/2.0/preview/accounts/c8edb4b9-2ef2-49e3-a043-aa7d9887433e/workspaces/4136265416458520/permissionassignments/principals/413050357358276) requires you to set `host` property (or DATABRICKS_HOST env variable) to result of `databricks_mws_workspaces.this.workspace_url`. This error may happen if you're using provider in both normal and multiworkspace mode. Please refactor your code into different modules. Runnable example that we use for integration testing can be found in this repository at https://registry.terraform.io/providers/databricks/databricks/latest/docs/guides/aws-workspace
with databricks_mws_permission_assignment.central_workspace_users_assignments["413050357358276"]
on groups_workspaces.tf line 66, in resource "databricks_mws_permission_assignment" "central_workspace_users_assignments":
resource "databricks_mws_permission_assignment" "central_workspace_users_assignments" {

Configuration

locals {
  central_databricks_workspace_users_list = [
    databricks_group.team_one.id,
    databricks_group.team_two.id,
  ]
}

resource "databricks_mws_permission_assignment" "central_workspace_users_assignments" {
  for_each     = toset(local.central_databricks_workspace_users_list)
  workspace_id = "foo"
  principal_id = each.value
  permissions  = ["USER"]
}

Terraform and provider versions

Terraform core version: 1.0.0 Databricks TF provider version: 1.6.2

nkvuong commented 1 year ago

This issue arises from the check for account API - https://github.com/databricks/terraform-provider-databricks/blob/master/common/http.go#L150

The API for permission assignment is /api/2.0/preview/accounts