Debugging Rule
Terraform errors are often platform-context errors presented through Terraform. Treat cloud dependencies and identity as first-class debugging dimensions.
Use practical runbooks for the most common real-world failures: state lock, drift, and failed apply executions.
| Symptom | Likely Area | First Check |
|---|---|---|
| init fails | Provider or backend | Version and backend config |
| plan fails | Auth or schema mismatch | Credentials and provider args |
| state lock error | Concurrent run or stale lock | Active jobs and lock metadata |
| unexpected replacement | Drift or refactor | State address and immutable fields |
| apply failed mid-run | Platform dependency or permission | Partial creation and cloud-side error details |
terraform validate terraform plan terraform state list terraform state show azurerm_kubernetes_cluster.platform terraform force-unlock LOCK_ID
terraform force-unlock LOCK_ID.terraform plan again to verify state consistency.Terraform errors are often platform-context errors presented through Terraform. Treat cloud dependencies and identity as first-class debugging dimensions.
I verify whether another valid run is still active before considering force-unlock.
Because partial resources may exist, and rerunning without understanding state can amplify damage.
I identify the intended source of truth, then align code and state with that decision deliberately.
Reliable Terraform operations come from repeatable debugging runbooks, not guesswork. Lock, drift, and failed-apply handling are core production skills.