Interview Prep/Terraform/State and Backends in Production

Applies keep failing with `Error acquiring the state lock` in CI. What do you do?

AdvancedProductionState and Backends in Production
Answer

First read the lock info (who, operation, created time). If a live run holds it, serialize runs: use a CI concurrency group per stack and -lock-timeout=10m so queued runs wait. If it is stale (cancelled job, runner died) confirm no process runs, then terraform force-unlock <ID>. Fix the cause: avoid cancelling apply jobs mid-run, and make pipeline cancellation graceful.

All Terraform questions Roadmap: Terraform in production

More on State and Backends in Production