databricks / terraform-provider-databricks

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

[Fix] Fix deletion of dashboard if it was trashed out of band #4235

Closed pietern closed 1 week ago

pietern commented 1 week ago

Changes

If a dashboard created by TF was trashed out of band, it could no longer be deleted by TF.

Example TF configuration:

terraform {
  required_providers {
    databricks = {
      source = "databricks/databricks"
      version = "1.58.0"
    }
  }
}

data "databricks_current_user" "me" {
  // This data source is used to get the current user's username
}

resource "databricks_dashboard" "this" {
  display_name = "Terraform test"
  parent_path = "/Workspace/Users/${data.databricks_current_user.me.user_name}/tf-dashboard-oob-deletion"
  warehouse_id = "58aa1b363649e722"
  serialized_dashboard = file("nyc_taxi_trip_analysis.lvdash.json")
}

If you apply this, and then run:

databricks lakeview trash <dashboard id>

The subsequent apply would error out with:

Error: cannot delete dashboard: dashboard [01efa39479a1128aae017018e434a747] lifecycle state [TRASHED] is not among the accepted states [Set(ACTIVE)]

It turns out trashing an already trashed dashboard returns an error.

This change guards against this condition returns success if the underlying dashboard has already been trashed.

Tests

github-actions[bot] commented 1 week ago

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger: go/deco-tests-run/terraform

Inputs:

Checks will be approved automatically on success.

eng-dev-ecosystem-bot commented 1 week ago

Test Details: go/deco-tests/11863430999