Terraform State Problems
Cheat sheet · https://pcornel.dk/topic.php?topic=6061
Answer
Terraform State Problems isolates failures involving backend access, workspace selection, state locks, serial/lineage, stale or missing objects, address moves, imports and divergence between Terraform/OpenTofu state and live infrastructure.
Remember
- State file exists ≠ correct backend/workspace is selected.
- Lock present ≠ lock is stale.
- Resource absent from state ≠ safe to create it.
- Import succeeds ≠ configuration and lifecycle semantics are complete.
First checks
terraform state list— contentsterraform force-unlock <id>— stale lock (verify first)terraform state pull > backup.tfstate— backup before fixes
Verify in this order
state issue → backup → state command → clean plan
Where it usually breaks
Terraform/OpenTofu state repair proves consistency only for the selected backend/workspace and modeled resources; it does not prove every external dependency or workload is healthy.
Terraform State Problems troubleshooting proof-boundary map
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Symptom / scope | Time window, immutable source/run identity, effective inputs and exact targets are explicit | Floating source, changed inputs or ambiguous targets destroy reproducibility |
| First failed boundary | Transport/auth/dependency/render/operation evidence identifies the earliest divergence | Investigation starts at the final error and skips earlier unproven boundaries |
| Effective outcome | Controller result is paired with target read-back and workload/service acceptance | Green execution state or changed symptom substitutes for effective-state verification |
| Recovery / closure | Minimal change restores the original test and regression/partial-state checks are clean | Broad retry or unrelated edits make the incident non-reproducible and hide residual state |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6061