Problem
You want to use Terraform to rename a metastore in Unity Catalog. Instead of modifying the metastore, Terraform destroys and recreates it.
Cause
Terraform detects this resource change as a new resource instead of a modification.
Solution
Rename the metastore using REST API
Perform a PATCH request to update the metastore name using the Databricks REST API.
curl --request PATCH "https://<your-databricks-instance>/api/2.1/unity-catalog/metastores/<your-metastore-unique-id>" \
--header "Authorization: Bearer <your-access-token>" \
--data '{ "name": "<your-metastore-new-name>" }'
For more information, consult the Update a metastore API documentation.
Update the metastore settings using the Unity Catalog CLI
In AWS and Azure, you can alternatively utilize the Unity Catalog CLI to modify the metastore configuration. Make a JSON file called update-metastore.json
, with the following content.
{
"name": "<your-metastore-new-name>"
}
Then run the following command.
databricks unity-catalog metastores update --id <your-metastore-unique-id> \
--json-file update-metastore.json
For more information, review the Unity Catalog CLI (legacy) (AWS | Azure) documentation.