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 #2380

Closed rishabhtrivedi23 closed 1 year ago

rishabhtrivedi23 commented 1 year ago

Configuration

# Copy-paste your Terraform configuration here

provider.tf

terraform { required_providers { databricks = { source = "databricks/databricks" version = "1.17.0" } google = { source = "hashicorp/google" version = "4.65.0" } } }

provider "google" { project = var.google_project_name region = var.google_region }

provider "databricks" { alias = "accounts" host = var.account_console_url account_id = var.databricks_account_id google_service_account = var.google_service_account_email rate_limit = 2 }

provider "databricks" { alias = "workspace" host = var.admin_workspace_url google_service_account = var.google_service_account_email account_id = var.databricks_account_id rate_limit = 2 }

module.tf

resource "databricks_mws_permission_assignment" "admin_group" { provider = databricks.ac workspace_id = databricks_mws_workspaces.workspace.workspace_id principal_id = data.databricks_group.admin_group.id permissions = ["ADMIN"] }

resource "databricks_mws_permission_assignment" "user_group" { provider = databricks.ac workspace_id = databricks_mws_workspaces.workspace.workspace_id principal_id = data.databricks_group.user_group.id permissions = ["USER"] } main.tf

module "workspace" { providers = { databricks.ac = databricks.accounts databricks.ws = databricks.workspace }

Expected Behavior

It should assign permissions.

Actual Behavior

Error: cannot create mws permission assignment: Permission assignment APIs are not available for this workspace. │ │ with module.workspace.databricks_mws_permission_assignment.user_group, │ on ......\modules\databricks\buildworkspace\buildworkspace.tf line 73, in resource "databricks_mws_permission_assignment" "user_group": │ 73: resource "databricks_mws_permission_assignment" "user_group" { │

Steps to Reproduce

Terraform and provider versions

Terraform v1.4.6 on windows_amd64

Debug Output

Important Factoids

We are also creating the workspace in same module, when we try to run this after 10-15 minutes, the same workflow runs fine. Do we need to add timer in between to wait for something ?

scheleaap commented 1 year ago

You might find this comment interesting because the user had the same error message.

rishabhtrivedi23 commented 1 year ago

@scheleaap The error message is same, However I followed the same approach which he is suggesting.

  1. We have already created a metastore in separate module.
  2. The workspace is getting created separately and then it is assigned to metastore (which is failing though https://github.com/databricks/terraform-provider-databricks/issues/2379).
  3. The above issue goes away if you try it after 20-30 mins or later, i.e. there is something wrong in response to creating workspace.
  4. I will provide debug logs next time.
rishabhtrivedi23 commented 1 year ago

This is resolved after using a workspace URL which is already part of unity metastore in provider.tf