terraform
state_error
ai_generated
true
Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed
ID: terraform/tf-state-lock-conflict
88%Fix Rate
90%Confidence
95Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1 | active | — | — | — |
Root Cause
Another Terraform process holds the state lock, or a previous run left a stale lock behind.
genericWorkarounds
-
90% success Use terraform force-unlock with the lock ID after verifying no other process is running
terraform force-unlock LOCK_ID (the lock ID is shown in the error message)
Sources: https://developer.hashicorp.com/terraform/cli/commands/force-unlock
-
85% success Wait for the other Terraform operation to complete
Check the Lock Info in the error for who holds the lock; verify with CI/CD system if a pipeline is running
Sources: https://developer.hashicorp.com/terraform/language/state/locking
Dead Ends
Common approaches that don't work:
-
Delete the DynamoDB lock table to clear the lock
90% fail
Deleting the table removes all locking protection and may cause state corruption from concurrent operations
-
Run terraform apply with -lock=false to bypass
75% fail
Bypassing locks risks concurrent state modifications and state file corruption
Error Chain
Preceded by:
Frequently confused with: