17. Common errors, decoded
One-liner. Most Terraform pain is state, locks, or cycles.
Memorize
Error acquiring the state lock→ another run crashed; confirm no active run, thenforce-unlock <id>.Provider produced inconsistent result→ usually a badignore_changesor a computed attribute fight; read the plan.Cycle: ...→ circular reference; break it withdepends_onremoval or split into modules/stacks.Error: resource already exists→ import it (block or CLI), don't delete it.No valid credential sources→ profile/SSO expired or CI role not assumed.Unsupported argumentafter upgrade → provider major version change; check the upgrade guide.Objects have changed outside of Terraform→ drift;plan -refresh-onlyto inspect, then decide.
Trap. Repeatedly force-unlock when a pipeline is actually running — you corrupt state, not fix it. Pick it when. the pipeline is red and everyone is guessing.