databricks / terraform-provider-databricks

Databricks Terraform Provider
https://registry.terraform.io/providers/databricks/databricks/latest
Other
445 stars 384 forks source link

[ISSUE] `databricks_mws_permission_assignment` resource plan returns `cannot reset nil reader` error #2679

Closed TMRert closed 1 year ago

TMRert commented 1 year ago

Configuration

# Account level provider, required to set up the metastore, metastore <- workspace assignments and user&group management
provider "databricks" {
  host       = "https://accounts.azuredatabricks.net"
  account_id = local.databricks_account_id
}

resource "databricks_metastore_assignment" "default_metastore" {
  workspace_id              = module.databricks_workspace.databricks_workspace_id
  metastore_id               = var.metastore_id
  default_catalog_name =local.project_catalog_name
}

# set up reader group to mirror AAD group with more comprehensible name
resource "databricks_group" "reader_group" {
  display_name = "${local.project_name} users"
  external_id      = var.project_group_aad_object_id
}

# assign user rights to reader group
resource "databricks_mws_permission_assignment" "add_reader_group" {
  workspace_id = module.databricks_workspace.databricks_workspace_id
  principal_id    = databricks_group.reader_group.id
  permissions   = ["USER"]
  depends_on   = [databricks_metastore_assignment.default_metastore]
}

Expected Behavior

The databricks_mws_permission_assignment resource is successfully created.

Actual Behavior

terraform plan fails with the following error:

│ Error: cannot read mws permission assignment: cannot reset nil reader
│ 
│   with module.databricks_uc_project["my_project"].databricks_mws_permission_assignment.add_reader_group,
│   on <path>/file.tf line 60, in resource "databricks_mws_permission_assignment" "add_reader_group":
│   60: resource "databricks_mws_permission_assignment" "add_reader_group" {

Steps to Reproduce

  1. terraform plan

Terraform and provider versions

Terraform v1.5.4
on linux_amd64
+ provider registry.terraform.io/databricks/databricks v1.25.0
+ provider registry.terraform.io/hashicorp/azuread v2.41.0
+ provider registry.terraform.io/hashicorp/azurerm v3.72.0

Debug Output

module.databricks_uc_project["my_project"].databricks_mws_permission_assignment.add_reader_group: Refreshing state... [id=4260204659545587|575375677552257]
2023-09-12T13:08:30.842Z [ERROR] provider.terraform-provider-databricks_v1.25.0: Response contains error diagnostic: diagnostic_severity=ERROR diagnostic_summary="cannot read mws permission assignment: cannot reset nil reader" tf_proto_version=5.4 tf_req_id=441a407d-900a-3052-5bdb-93a6e9a58e6e @caller=/home/runner/work/terraform-provider-databricks/terraform-provider-databricks/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_detail= tf_rpc=ReadResource tf_provider_addr=registry.terraform.io/databricks/databricks tf_resource_type=databricks_mws_permission_assignment timestamp=2023-09-12T13:08:30.842Z
2023-09-12T13:08:30.842Z [ERROR] vertex "module.databricks_uc_project[\"my_project\"].databricks_mws_permission_assignment.add_reader_group" error: cannot read mws permission assignment: cannot reset nil reader

Important Factoids

pietern commented 1 year ago

Thanks for reporting the issue.

This is a duplicate of #2675. We're working on releasing a fix in 1.25.1 today.