terraform-provider-databricks
terraform-provider-databricks copied to clipboard
Exporter: SQL objects are recreated when generated code is imported into the TF state for current workspace
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
ForceNewfromparent, but this will require validation that we can change theparentin the update operation (didn't work before) - add a new attribute like
home_object_idtodatabricks_useranddatabricks_service_principalto 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_directoryto work with user/SP folders (don't attempt to delete them on destroy, etc.) and use resources, not data sources.