cancel
Showing results for 
Search instead for 
Did you mean: 
Data Governance
Join discussions on data governance practices, compliance, and security within the Databricks Community. Exchange strategies and insights to ensure data integrity and regulatory compliance.
cancel
Showing results for 
Search instead for 
Did you mean: 

Having an issue assigning databricks_metastore with terraform provider

Awakz
New Contributor II

I am trying to assign my databricks_metastore on terraform and I get the following error back as an output `Error: cannot create metastore assignment: Workspace is not in the same region as metastore. Workspace region: Unknown, Metastore region: us-east-1`

Snippet

```

resource "databricks_metastore" "metastore" {

 provider   = databricks.created_workspace

 name     = "root-metastore"

 storage_root = "s3://${aws_s3_bucket.databricks_bucket.id}/metastore"

 force_destroy = true

}

resource "databricks_metastore_data_access" "this" {

 provider  = databricks.created_workspace

 metastore_id = databricks_metastore.metastore.id

 name    = aws_iam_role.databricks_role.name

 aws_iam_role { role_arn = aws_iam_role.databricks_role.arn }

depends_on = [databricks_metastore_assignment.this]

 is_default = true

}

resource "databricks_metastore_assignment" "this" {

 provider  = databricks.created_workspace

 metastore_id = databricks_metastore.metastore.id

 workspace_id = var.default_metastore_workspace_id

 depends_on = [databricks_metastore.metastore]

}

```

As you can see here there's definitely a value set for databricks_mws_workspaces

```

resource "databricks_mws_workspaces" "this" {

 depends_on  = [databricks_mws_networks.this]

 provider   = databricks.mws

 account_id  = var.databricks_account_id

 workspace_name = var.prefix

 aws_region  = var.region

 credentials_id     = databricks_mws_credentials.this.credentials_id

 storage_configuration_id = databricks_mws_storage_configurations.this.storage_configuration_id

 network_id       = databricks_mws_networks.this.network_id

 token {}

}

```

terraform.tfvars - aws_region = "us-east-1"

While checking the UI it does state both workspace and metastore are both us-east-1 yet this issue still occurs.

I can set it manually but would like to automate it using terraform.

4 REPLIES 4

Debayan
Databricks Employee
Databricks Employee

Hi, This can be a bug, could you please confirm if the same happens when you try to do it through the UI or notebook?

Awakz
New Contributor II

Blessings debayan,

I've successfully managed doing this through the UI but it failes on terraform.

lucasvieira
New Contributor III

There is an open issue in the Databricks terraform provider https://github.com/databricks/terraform-provider-databricks/issues/2513 and someone found a workaround and post in this comment https://github.com/databricks/terraform-provider-databricks/issues/2513#issuecomment-1653764528

 

youssefmrini
Databricks Employee
Databricks Employee

The error message you received indicates that the Databricks workspace region is different from the region where the metastore is located. The message shows that the workspace region is "Unknown", which means that Databricks is unable to determine the region for the workspace.

To resolve this issue, you can explicitly set the Databricks workspace region in your Terraform configuration. To do this, you can add the region parameter to your databricks.created_workspace provider block, like this:

 

text
provider "databricks" {
  region = var.region
  # ... other provider configuration ...
}

Make sure to populate the region variable with the region where your Databricks workspace is hosted. You can also try to specify the region in the databricks.created_workspace provider block directly, without using a variable.

Once you've added the region parameter to your provider block, rerun your Terraform deployment to create and assign the Databricks metastore. With the region parameter set correctly, you should be able to create a metastore assignment successfully.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group