Introduction:
When working with Terraform, warnings about deprecated resources may appear. For instance, a warning might indicate, for example, databricks_catalog_workspace_binding
is deprecated and should be replaced with databricks_workspace_binding
. Directly changing the resource type can cause the old resource to be removed and a new one to be created, potentially locking out the workspace.
Expected Outcome
The deprecated resource will be updated to the new resource type without causing downtime or locking out the workspace.
Prerequisites (if applicable)
- Terraform CLI installed
- Access to the Terraform state file
- Permissions to modify the state and import resources
Use Case
Updating deprecated resources in Terraform configurations to ensure compatibility with future versions and avoid potential issues.
Procedure
-
Change the Run Method to CLI:
-
Update the Terraform Cloud run method to CLI to perform CLI commands on the workspace.
-
-
Remove the Deprecated Resource from the State File:
- Use the
terraform state rm
command to remove the deprecated resource from the state file. - Like this:
terraform state rm databricks_catalog_workspace_binding.workspace_name
- Use the
-
Update the Terraform Configuration:
-
Change the resource type in the Terraform configuration from
databricks_catalog_workspace_binding
todatabricks_workspace_binding
.
-
-
Import the Resource to the New Configuration:
- Use the
terraform import
command to map the existing resource to the new resource type in the updated configuration. terraform import databricks_workspace_binding.workspace_name <resource_id>
- Use the
Additional Information
-
Terraform Cloud CLI: https://developer.hashicorp.com/terraform/cli/cloud
-
Terraform State rm: https://developer.hashicorp.com/terraform/cli/commands/state/rm
- Terraform Import: https://developer.hashicorp.com/terraform/cli/import
-
Ensure a backup of the state file is created before performing these operations.
-
Review the Terraform documentation for any additional changes required for the new resource type.
The information contained in this article has been verified as up-to-date on the date of the original publication of the article. HashiCorp endeavors to keep this information up-to-date and correct, but it makes no representations or warranties of any kind, express or implied, about the ongoing completeness, accuracy, reliability, or suitability of the information provided.
All information contained in this article is for general information purposes only. Any reliance you place on such information as it applies to your use of your HashiCorp product is therefore strictly at your own risk.