A CI job crashed and the lock remains. When is `force-unlock` acceptable?
AdvancedScenarioState Backends and Workspaces
Answer
Situation read → A stale lock from a killed runner blocks everyone.
What I'd do →
- Confirm via the lock info (ID, who, when) and CI that no run is active.
- Check the state isn't partially written: compare the latest S3 version and look at logs.
- Run
terraform force-unlock <LOCK_ID>. - Run
planto verify state and reality agree.
Why → Unlocking while a real apply is running can corrupt state. Verify, then unlock, then re-plan.
Interview tip → With use_lockfile, the lock is an S3 object, which you can also inspect and delete.
More on State Backends and Workspaces
Two engineers keep overwriting each other's changes because state is local. What's the fix?BeginnerSet up a production-grade S3 backend. What do you configure for locking?IntermediateHow do you harden the S3 bucket that holds Terraform state?IntermediateWho creates the state bucket itself, given Terraform needs it to exist before `init`?IntermediateA laptop apply and a CI apply start at the same time. What stops state corruption?IntermediateWhen are Terraform workspaces appropriate?Beginner