Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE] Issue with databricks_metastore_data_access resource: cannot delete metastore #4075

Open
dfanesiDB opened this issue Oct 5, 2024 · 0 comments

Comments

@dfanesiDB
Copy link
Contributor

dfanesiDB commented Oct 5, 2024

Hi there,

if you create a unity catalog metastore with data access settings, it's impossible to destroy the resource after create because data access depends on metastore and by deleting data access first, an error is triggered because the data access is used by the metastore.

deleting the metastore, will also delete the related data access, so ideally terraform should skip the destroy of data access and destroy the metastore directly, or we should at least have a flag to enforce this behaviour. The only solution is to delete metastore from UI and then call destroy again.

Configuration

resource "databricks_metastore" "this" {
  provider        = databricks.mws
  name          = "primary"
  storage_root  = "s3://${var.root_bucket}/metastore"
  region        = var.region
  force_destroy = true
}

resource "databricks_metastore_assignment" "this" {
  provider        = databricks.mws
  metastore_id = databricks_metastore.this.id
  workspace_id = split("/", databricks_mws_workspaces.this.id)[1]
}

resource "databricks_metastore_data_access" "this" {
  provider        = databricks.mws
  metastore_id = databricks_metastore.this.id
  name         = var.aws_iam_role_metastore_name
  aws_iam_role {
    role_arn = var.aws_iam_role_metastore_arn
  }
  is_default = true
  depends_on = [databricks_mws_credentials.this]
  lifecycle {
    ignore_changes = [
      is_default
    ]
  }
}

Expected Behavior

deleting the metastore, will also delete the related data access, so ideally terraform should skip the destroy of data access and destroy the metastore directly, or we should at least have a flag to enforce this behaviour. The only solution is to delete metastore from UI and then call destroy again.

Actual Behavior

it's impossible to destroy the resource after create because data access depends on metastore and by deleting data access first, an error is triggered because the data access is used by the metastore.

Error: cannot delete metastore data access: Storage credential 'databricks-metastore' cannot be deleted because it is configured as this metastore's root credential. Please update the metastore's root credential before attempting deletion.

Steps to Reproduce

create a terraform template as shown above. apply, then destroy

Terraform and provider versions

1.52.0

Is it a regression?

no

Debug Output

Important Factoids

Would you like to implement a fix?

no

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant