szymon_dybczak
Esteemed Contributor III

 

 

 

 

Hi @JustLeo , 

You haven't provided how you defined resource, but maybe you're missing depends on clause?

According to terraform documentation:

In Terraform 0.13 and later, data resources have the same dependency resolution behavior as defined for managed resources. Most data resources make an API call to a workspace. If a workspace doesn't exist yet, default auth: cannot configure default credentials error is raised. To work around this issue and guarantee a proper lazy authentication with data resources, you should add depends_on = [azurerm_databricks_workspace.this] or depends_on = [databricks_mws_workspaces.this] to the body. This issue doesn't occur if a workspace is created in one module and resources within the workspace are created in another. We do not recommend using Terraform 0.12 and earlier if your usage involves data resources.

You can also compare your provider configuration to one below, which comes from official terraform guide. To create metastore and perform metastore assignment to workspace, they're using provider with an alias "accounts":

https://registry.terraform.io/providers/databricks/databricks/latest/docs/guides/unity-catalog-azure...

provider "databricks" {
  host = local.databricks_workspace_host
}

provider "databricks" {
  alias      = "accounts"
  host       = "https://accounts.azuredatabricks.net"
  account_id = var.databricks_account_id
}

 

You can also take a look on below thread with kind of similar problem: 

https://community.databricks.com/t5/data-governance/issue-creating-metastore-using-terraform-with-se...

View solution in original post