Purpose: Pre-flight checklist to ensure successful deployment and prevent common issues.
Use this checklist before running terraform apply or terraform destroy.
force_destroy is set to true
# modules/unity-catalog/main.tf
resource "databricks_metastore" "this" {
force_destroy = true # REQUIRED for clean destroy
}
# modules/networking/nsg-rules.tf
resource "azurerm_network_security_rule" "example" {
count = var.enable_private_link ? 1 : 0 # Only for PL
}
default_action = "Allow" initially
# modules/unity-catalog/main.tf
network_rules {
default_action = "Allow" # Required for container creation
}
# deployments/non-pl/terraform.tfvars
tag_owner = "your-email@company.com"
tag_keepuntil = "MM/DD/YYYY"
# deployments/non-pl/main.tf
resource "random_string" "deployment_suffix" {
length = 4
}
export ARM_SUBSCRIPTION_ID="..."
export ARM_TENANT_ID="..."
# If using service principal:
export ARM_CLIENT_ID="..."
export ARM_CLIENT_SECRET="..."
export DATABRICKS_ACCOUNT_ID="..."
export DATABRICKS_AZURE_TENANT_ID="$ARM_TENANT_ID"
az account show
echo $DATABRICKS_ACCOUNT_ID
terraform version
# deployments/non-pl/versions.tf
azurerm ~> 3.100
databricks ~> 1.40
random ~> 3.6
terraform {
backend "azurerm" {
# ...
}
}
terraform.tfvars is populated
# Required variables
workspace_prefix = "..."
location = "eastus2"
databricks_account_id = "..."
metastore_name = "..."
terraform init
terraform validate
terraform plan -out=tfplan
# Review the plan carefully!
# Check via Databricks UI or API
databricks clusters list
databricks jobs list
terraform plan -destroy
# Remove metastore from state (does not delete in Databricks)
terraform state rm 'module.unity_catalog.databricks_metastore_data_access.this[0]'
terraform state rm 'module.unity_catalog.databricks_metastore.this[0]'
# Update subnets to remove SEP first
terraform apply -target=module.networking.azurerm_subnet.public \
-target=module.networking.azurerm_subnet.private \
-auto-approve
terraform destroy -auto-approve
az resource list --resource-group rg-databricks-prod-eastus2
# Only if metastore should be deleted
databricks metastores delete --metastore-id <id> --account-id <account-id>
β Setting force_destroy = false or not setting it at all
# DON'T DO THIS
resource "databricks_metastore" "this" {
force_destroy = false # β Will block destroy
}
β
Always use force_destroy = true
# DO THIS
resource "databricks_metastore" "this" {
force_destroy = true # β
Allows clean destroy
}
β Adding lifecycle.ignore_changes for force_destroy
# DON'T DO THIS
resource "databricks_metastore" "this" {
force_destroy = true
lifecycle {
ignore_changes = [force_destroy] # β Prevents destroy
}
}
β No lifecycle ignore for force_destroy
# DO THIS
resource "databricks_metastore" "this" {
force_destroy = true # β
No lifecycle block
}
β Creating NSG rules for Non-PL deployments
# DON'T DO THIS
resource "azurerm_network_security_rule" "example" {
# This will conflict with Databricks auto-created rules
}
β Conditional NSG rules for Private Link only
# DO THIS
resource "azurerm_network_security_rule" "example" {
count = var.enable_private_link ? 1 : 0 # β
Only for PL
}
β Storage account with default_action = "Deny" initially
# DON'T DO THIS
resource "azurerm_storage_account" "example" {
network_rules {
default_action = "Deny" # β Blocks container creation
}
}
β Allow initial access for container creation
# DO THIS
resource "azurerm_storage_account" "example" {
network_rules {
default_action = "Allow" # β
Required initially
}
}
β Missing DATABRICKS_AZURE_TENANT_ID
# DON'T FORGET THIS
export DATABRICKS_AZURE_TENANT_ID="..." # β Often forgotten
β Always export tenant ID
# DO THIS
export DATABRICKS_AZURE_TENANT_ID="$ARM_TENANT_ID" # β
Required
β Running destroy without checking metastore usage
# DON'T DO THIS
terraform destroy -auto-approve # β May delete shared metastore
β Check metastore dependencies first
# DO THIS
databricks metastores get --metastore-id <id> --account-id <account-id>
# Check if used by other workspaces
terraform destroy -auto-approve
β All resources created without errors β Workspace accessible at returned URL β Unity Catalog metastore assigned β External location created and accessible β NCC attached to workspace (serverless-ready) β Tags applied to all resources β Random suffixes prevent naming conflicts
Verify NCC:
terraform output ncc_id
# Expected: ncc-<id>
terraform output ncc_name
# Expected: <workspace-prefix>-ncc
βΈοΈ Enable Serverless Compute:
β All Azure resources deleted β No orphaned resources remain β Terraform state is clean β (Optional) Metastore deleted if intended β NCC binding removed (or kept for reuse)
If you encounter issues:
export TF_LOG=DEBUG
terraform apply 2>&1 | tee debug.log
Document Version: 1.1 Next Review: Before each major deployment