terraform-troubleshootinglisted
Install: claude install-skill riteshsonawane1372/devops-skills
# Terraform Troubleshooting
Diagnose Terraform errors by working out which of the four layers is wrong: configuration, state,
provider, or the real world.
## Purpose
**Use this when:**
- `terraform plan` or `apply` fails with an error.
- An apply hangs, or fails with `Error acquiring the state lock`.
- The plan shows changes that make no sense, or never converges.
- An apply failed partway and you do not know what state is in.
- `Error: Invalid for_each argument` / `Provider produced inconsistent final plan` / `Cycle:`.
**Do not use this when:**
- The plan is correct and you are deciding whether to apply it — use `terraform-review`.
- You are executing a normal change — use `terraform-safe-changes`.
**What this skill assumes:** the exact error text. Terraform errors are specific and the message
usually names the resource and the attribute; paraphrased errors are not diagnosable.
## Operating Procedure
1. **Capture the exact error.** Full text, resource address, and the command that produced it.
2. **Identify the layer.** Configuration (HCL is wrong), state (Terraform's belief is wrong),
provider (the plugin or its credentials are wrong), or reality (the cloud disagrees).
3. **Reproduce read-only.** `terraform validate`, then `plan`, before touching anything.
4. **Check the obvious environmental causes first**: wrong workspace, expired credentials, stale
provider cache, a concurrent run.
5. **Fix at the right layer.** Configuration problems are fixed in code. St