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_assignment resource #2489

Open
arothian opened this issue Jul 18, 2023 · 3 comments
Open

[ISSUE] Issue with databricks_metastore_assignment resource #2489

arothian opened this issue Jul 18, 2023 · 3 comments

Comments

@arothian
Copy link

The databricks_metastore_assignment incorrectly refreshes state from the API.

Configuration

resource "databricks_metastore_assignment" "metastore_assignment" {
  provider             = databricks.workspace
  workspace_id         = databricks_mws_workspaces.this.workspace_id
  metastore_id         = databricks_metastore.metastore.id
  default_catalog_name = var.default_catalog_name
}

databricks.workspace points to a provider configuration interacting with the workspace API, using workspace created externally from the TF code. Let's call it Workspace Control
databricks_mws_workspaces.this defines a workspace being managed, Workspace This.
databricks_metastore.metastore.id defines a metastore being managed.

Expected Behavior

When terraform plan is executed, the state should refresh and correctly mirror the actual resources.

Actual Behavior

When first applied, Workspace This is correctly associated to the metastore. However, subsequent refreshes of state, such as those when executing terraform plan, indicate that the association needs to be updated:

  ~ resource "databricks_metastore_assignment" "metastore_assignment" {
        id                   = "<workspace-this-id>|<metastore.id>"
      ~ metastore_id         = "<metastore for workspace control>" -> "<metastore.id"
        # (2 unchanged attributes hidden)
    }

This seems to occur because of the API call used during read simply returns the metastore of the workspace associated with the databricks provider. If your provider is a different workspace than the one identified in the resource, it retrieves the wrong metastore id.

Steps to Reproduce

terraform plan

Terraform and provider versions

Terraform v1.4.6
on darwin_arm64
+ provider registry.terraform.io/databricks/databricks v1.21.0
+ provider registry.terraform.io/hashicorp/aws v5.7.0

Debug Output

NA

Important Factoids

This occurs because the databricks provider is using a different workspace than the metastore assignment workspace being managed. The metastore for the workspace used by the provider is not the same as the one being associated in the terraform resource. The resource allows you to create these assignments, but then it doesn't correctly read the state afterwards. Moving this resource to use the account-level API would resolve this issue as there is no workspace-level API to read metastore assignments, only create, update and delete.

@arothian
Copy link
Author

Similar to #2061 but under different circumstances.

@arothian
Copy link
Author

Looks like PR #2182 should resolve this by using the account level API

@mgyucht
Copy link
Contributor

mgyucht commented Aug 28, 2023

Can you try the account-level API and verify that this issue is resolved?

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

2 participants