debugterraformMajor
Terraform state lock stuck — cannot acquire lock
Viewed 0 times
state lockforce-unlockDynamoDBlock timeoutconcurrent terraform
ci-cdterminal
Error Messages
Problem
Terraform plan/apply fails with Error acquiring the state lock after a previous run was interrupted.
Solution
First verify no one else is running Terraform. If stale: terraform force-unlock <LOCK_ID>. For DynamoDB backend: check the lock table and delete stale item. Prevention: (1) Let Terraform finish or use Ctrl+C (releases lock gracefully). (2) Set -lock-timeout=5m for CI. (3) Use CI/CD systems that serialize Terraform runs.
Why
Terraform locks state to prevent concurrent modifications. If a run is killed mid-operation, the lock is not released because the cleanup handler never runs.
Revisions (0)
No revisions yet.