terraform-provider-databricks icon indicating copy to clipboard operation
terraform-provider-databricks copied to clipboard

Exporter: SQL objects are recreated when generated code is imported into the TF state for current workspace

Open alexott opened this issue 1 year ago • 0 comments

There is an edge case when an SQL object (dashboard/query/alert) is in the user home folder, not a subfolder - in this case instead of a reference to a resource, we generated a reference to the data source, and because parent is marked as ForceNew it leads to SQL object recreation when importing existing SQL objects into the TF state.

#3112 attempted to fix it by removing references when an object is in the user's directory, but it was incorrect as it will lead to creating the objects in the home folder of the user who is doing terraform apply, instead of creating them in directories of specific users.

Possible approaches to fix are:

  • remove ForceNew from parent, but this will require validation that we can change the parent in the update operation (didn't work before)
  • add a new attribute like home_object_id to databricks_user and databricks_service_principal to expose object ID of their home directories. Main drawback - it won't work well because we will need to use data sources when support for Identity Federation will be added to the exporter.
  • change databricks_directory to work with user/SP folders (don't attempt to delete them on destroy, etc.) and use resources, not data sources.

alexott avatar Jan 14 '24 12:01 alexott