databricks / terraform-provider-databricks

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

[ISSUE] Issue with `databricks_mws_permission_assignment` resource #2676

Closed thaiphv closed 1 year ago

thaiphv commented 1 year ago

Configuration

data "databricks_group" "workspace_access" {
  for_each = toset(local.unity_catalog_workspace_groups)

  display_name = each.value

  provider = databricks.mws
}

resource "databricks_mws_permission_assignment" "workspace_access" {
  for_each = toset(local.unity_catalog_workspace_groups)

  workspace_id = var.databricks_workspace_id
  principal_id = data.databricks_group.workspace_access[each.value].id
  permissions  = ["USER"]

  provider = databricks.mws
}

Expected Behavior

The resources are created successfully

Actual Behavior

As there are dozens of workspace assignments in my project, the TF code failed at random databricks_mws_permission_assignment resources.

Steps to Reproduce

  1. terraform apply

Terraform and provider versions

Terraform: 1.4.6 Databricks provider: 1.25.0

Debug Output

2023-09-12T12:39:07.475+1000 [DEBUG] ReferenceTransformer: "module.powerbi_service_principal.aws_ssm_parameter.this" references: []
2023-09-12T12:39:07.565+1000 [INFO]  ReferenceTransformer: reference not found: "var.service_principals"
2023-09-12T12:39:07.565+1000 [INFO]  ReferenceTransformer: reference not found: "databricks_service_principal.this"
2023-09-12T12:39:07.565+1000 [INFO]  ReferenceTransformer: reference not found: "each.key"
2023-09-12T12:39:07.565+1000 [INFO]  ReferenceTransformer: reference not found: "var.environment"
2023-09-12T12:39:07.565+1000 [INFO]  ReferenceTransformer: reference not found: "local.workspace_name"
2023-09-12T12:39:07.565+1000 [INFO]  ReferenceTransformer: reference not found: "each.key"
2023-09-12T12:39:07.565+1000 [INFO]  ReferenceTransformer: reference not found: "databricks_obo_token.this"
2023-09-12T12:39:07.565+1000 [INFO]  ReferenceTransformer: reference not found: "each.key"
2023-09-12T12:39:07.565+1000 [DEBUG] ReferenceTransformer: "module.workspace_project_breach_reporting.aws_ssm_parameter.this[\"AutomatedTest\"]" references: []
2023-09-12T12:39:08.055+1000 [ERROR] provider.terraform-provider-databricks_v1.25.0: Response contains error diagnostic: @caller=/home/runner/work/terraform-provider-databricks/terraform-provider-databricks/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/diag/diagnostics.go:58 diagnostic_detail= diagnostic_severity=ERROR diagnostic_summary="cannot read mws permission assignment: cannot reset nil reader" tf_resource_type=databricks_mws_permission_assignment tf_rpc=ReadResource @module=sdk.proto tf_proto_version=5.4 tf_provider_addr=registry.terraform.io/databricks/databricks tf_req_id=b55a7490-458b-6803-c81f-4ce41d6d7892 timestamp=2023-09-12T12:39:08.055+1000
2023-09-12T12:39:08.056+1000 [ERROR] vertex "module.workspace_team_strategic_intelligence.databricks_mws_permission_assignment.workspace_access[\"App.DataLake.Dev.Workspace.Team.StrategicIntelligence_Admin\"]" error: cannot read mws permission assignment: cannot reset nil reader
2023-09-12T12:39:08.991+1000 [ERROR] provider.terraform-provider-databricks_v1.25.0: Response contains error diagnostic: diagnostic_detail= tf_provider_addr=registry.terraform.io/databricks/databricks tf_req_id=71a98e22-57db-aab0-aedd-c82514374dd4 tf_resource_type=databricks_mws_permission_assignment @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_severity=ERROR diagnostic_summary="cannot read mws permission assignment: cannot reset nil reader" tf_proto_version=5.4 tf_rpc=ReadResource timestamp=2023-09-12T12:39:08.991+1000
2023-09-12T12:39:08.991+1000 [ERROR] vertex "module.workspace_project_ml_breach_referral_automation.databricks_mws_permission_assignment.workspace_access[\"App.DataLake.Dev.Workspace.Project.MlBreReferralAuto\"]" error: cannot read mws permission assignment: cannot reset nil reader
2023-09-12T12:39:09.007+1000 [ERROR] provider.terraform-provider-databricks_v1.25.0: Response contains error diagnostic: tf_proto_version=5.4 tf_provider_addr=registry.terraform.io/databricks/databricks tf_req_id=31f8b5ee-8648-d7d7-72d3-1e244f71a836 tf_rpc=ReadResource diagnostic_summary="cannot read mws permission assignment: cannot reset nil reader" diagnostic_detail= diagnostic_severity=ERROR tf_resource_type=databricks_mws_permission_assignment @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 timestamp=2023-09-12T12:39:09.007+1000
2023-09-12T12:39:09.007+1000 [ERROR] vertex "module.workspace_team_mobr_data_stream.databricks_mws_permission_assignment.workspace_access[\"App.DataLake.Dev.Workspace.Team.MoBRDatastream\"]" error: cannot read mws permission assignment: cannot reset nil reader
2023-09-12T12:39:09.060+1000 [ERROR] provider.terraform-provider-databricks_v1.25.0: Response contains error diagnostic: diagnostic_detail= diagnostic_severity=ERROR tf_proto_version=5.4 tf_provider_addr=registry.terraform.io/databricks/databricks tf_req_id=b5fee9ac-a9a5-fbdf-057a-66f34cac70f4 tf_resource_type=databricks_mws_permission_assignment @module=sdk.proto diagnostic_summary="cannot read mws permission assignment: cannot reset nil reader" tf_rpc=ReadResource @caller=/home/runner/work/terraform-provider-databricks/terraform-provider-databricks/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/diag/diagnostics.go:58 timestamp=2023-09-12T12:39:09.060+1000
2023-09-12T12:39:09.060+1000 [ERROR] vertex "module.workspace_project_markets_server_replacement.databricks_mws_permission_assignment.workspace_access[\"App.DataLake.Dev.Workspace.Project.MarketsServerReplacement_Admi\"]" error: cannot read mws permission assignment: cannot reset nil reader
2023-09-12T12:39:09.068+1000 [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_resource_type=databricks_mws_permission_assignment tf_rpc=ReadResource @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 tf_provider_addr=registry.terraform.io/databricks/databricks tf_req_id=addf90f4-3351-cab8-6e73-ff1d04479205 diagnostic_detail= timestamp=2023-09-12T12:39:09.068+1000
2023-09-12T12:39:09.069+1000 [ERROR] vertex "module.workspace_project_super_data_transfer_apra_to_asic.databricks_mws_permission_assignment.workspace_access[\"App.DataLake.Dev.Workspace.Project.SprDataApraToAsic_Admin\"]" error: cannot read mws permission assignment: cannot reset nil reader
2023-09-12T12:39:09.455+1000 [INFO]  ReferenceTransformer: reference not found: "databricks_notebook.userlogs"
2023-09-12T12:39:09.455+1000 [INFO]  ReferenceTransformer: reference not found: "databricks_mws_permission_assignment.workspace_access"
2023-09-12T12:39:09.455+1000 [INFO]  ReferenceTransformer: reference not found: "var.cluster_admin_ad_group"
2023-09-12T12:39:09.455+1000 [INFO]  ReferenceTransformer: reference not found: "var.workspace_type"
2023-09-12T12:39:09.455+1000 [INFO]  ReferenceTransformer: reference not found: "var.workspace_type"
2023-09-12T12:39:09.455+1000 [INFO]  ReferenceTransformer: reference not found: "var.workspace_name"
2023-09-12T12:39:09.455+1000 [INFO]  ReferenceTransformer: reference not found: "var.cluster_admin_ad_group"
2023-09-12T12:39:09.455+1000 [DEBUG] ReferenceTransformer: "module.workspace_project_internal_dispute_resolution.databricks_permissions.userlogs[0]" references: []
2023-09-12T12:39:09.469+1000 [INFO]  ReferenceTransformer: reference not found: "databricks_notebook.userlogs"
2023-09-12T12:39:09.469+1000 [INFO]  ReferenceTransformer: reference not found: "databricks_mws_permission_assignment.workspace_access"
2023-09-12T12:39:09.469+1000 [INFO]  ReferenceTransformer: reference not found: "var.cluster_admin_ad_group"
2023-09-12T12:39:09.469+1000 [INFO]  ReferenceTransformer: reference not found: "var.workspace_type"
2023-09-12T12:39:09.469+1000 [INFO]  ReferenceTransformer: reference not found: "var.workspace_type"
2023-09-12T12:39:09.469+1000 [INFO]  ReferenceTransformer: reference not found: "var.workspace_name"
2023-09-12T12:39:09.469+1000 [INFO]  ReferenceTransformer: reference not found: "var.cluster_admin_ad_group"
2023-09-12T12:39:09.469+1000 [DEBUG] ReferenceTransformer: "module.workspace_project_intergidredrrepsit.databricks_permissions.userlogs[0]" references: []
2023-09-12T12:39:09.650+1000 [ERROR] vertex "module.workspace_team_mobr_data_stream.databricks_mws_permission_assignment.workspace_access (expand)" error: cannot read mws permission assignment: cannot reset nil reader
2023-09-12T12:39:09.768+1000 [ERROR] vertex "module.workspace_team_strategic_intelligence.databricks_mws_permission_assignment.workspace_access (expand)" error: cannot read mws permission assignment: cannot reset nil reader
2023-09-12T12:39:09.769+1000 [INFO]  ReferenceTransformer: reference not found: "databricks_notebook.userlogs"
2023-09-12T12:39:09.769+1000 [INFO]  ReferenceTransformer: reference not found: "databricks_mws_permission_assignment.workspace_access"
2023-09-12T12:39:09.769+1000 [INFO]  ReferenceTransformer: reference not found: "var.cluster_admin_ad_group"
2023-09-12T12:39:09.769+1000 [INFO]  ReferenceTransformer: reference not found: "var.workspace_type"
2023-09-12T12:39:09.769+1000 [INFO]  ReferenceTransformer: reference not found: "var.workspace_type"
2023-09-12T12:39:09.769+1000 [INFO]  ReferenceTransformer: reference not found: "var.workspace_name"
2023-09-12T12:39:09.769+1000 [INFO]  ReferenceTransformer: reference not found: "var.cluster_admin_ad_group"
2023-09-12T12:39:09.769+1000 [DEBUG] ReferenceTransformer: "module.workspace_team_nlp_registered_liquidators.databricks_permissions.userlogs[0]" references: []
2023-09-12T12:39:09.850+1000 [ERROR] provider.terraform-provider-databricks_v1.25.0: Response contains error diagnostic: @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= diagnostic_severity=ERROR diagnostic_summary="cannot read mws permission assignment: cannot reset nil reader" tf_provider_addr=registry.terraform.io/databricks/databricks tf_req_id=09f63eb6-d378-8c16-1bd4-7c2b65db7b91 tf_rpc=ReadResource tf_proto_version=5.4 tf_resource_type=databricks_mws_permission_assignment timestamp=2023-09-12T12:39:09.849+1000
2023-09-12T12:39:09.850+1000 [ERROR] vertex "module.workspace_team_office_of_enforcement.databricks_mws_permission_assignment.workspace_access[\"App.DataLake.Dev.Workspace.Team.OfficeofEnforcement\"]" error: cannot read mws permission assignment: cannot reset nil reader
2023-09-12T12:39:09.857+1000 [ERROR] provider.terraform-provider-databricks_v1.25.0: Response contains error diagnostic: diagnostic_severity=ERROR tf_proto_version=5.4 tf_provider_addr=registry.terraform.io/databricks/databricks tf_resource_type=databricks_mws_permission_assignment tf_rpc=ReadResource diagnostic_detail= diagnostic_summary="cannot read mws permission assignment: cannot reset nil reader" tf_req_id=f1c4cbd6-98f7-65a0-80a9-817dfe2643a3 @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 timestamp=2023-09-12T12:39:09.857+1000
2023-09-12T12:39:09.857+1000 [ERROR] vertex "module.workspace_project_information_resource_centre.databricks_mws_permission_assignment.workspace_access[\"App.DataLake.Dev.Workspace.Project.InfResCentre_Admin\"]" error: cannot read mws permission assignment: cannot reset nil reader
2023-09-12T12:39:09.887+1000 [INFO]  ReferenceTransformer: reference not found: "databricks_notebook.userlogs"
2023-09-12T12:39:09.887+1000 [INFO]  ReferenceTransformer: reference not found: "databricks_mws_permission_assignment.workspace_access"

Important Factoids

This issue doesn't happen with <1.25.0

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.