debugMajorpending
Terraform state lock -- stuck lock after crashed apply
Viewed 0 times
state lockforce-unlockDynamoDBS3 backendconcurrent modification
terminalaws
Error Messages
Problem
Terraform refuses to plan or apply with 'Error acquiring the state lock'. A previous terraform apply crashed or was interrupted, leaving the state locked.
Solution
First verify no other process is actually running terraform. Then: terraform force-unlock LOCK_ID. The lock ID is shown in the error message. For S3 backend, the lock is stored in DynamoDB. Never force-unlock while another apply is running -- this can corrupt state. If state is corrupted: terraform state pull > backup.json, fix manually, terraform state push backup.json.
Why
Terraform locks state to prevent concurrent modifications. If the process crashes before releasing the lock, it stays locked until manually cleared.
Revisions (0)
No revisions yet.