ConditionalCheckFailedException
terraform
resource_error
ai_generated
true
Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed: The conditional request failed
ID: terraform/state-lock-dynamodb-conditional-check-failed
90%Fix Rate
85%Confidence
1Evidence
2023-05-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Terraform 1.5 | active | — | — | — |
| Terraform 1.6 | active | — | — | — |
| Terraform 1.7 | active | — | — | — |
| AWS Provider 5.0+ | active | — | — | — |
Root Cause
DynamoDB state lock table's condition expression failed, typically because another process holds the lock or the lock record is stale.
generic中文
DynamoDB 状态锁表的条件表达式失败,通常是因为另一个进程持有锁或锁记录已过期。
Official Documentation
https://developer.hashicorp.com/terraform/language/state/lockingWorkarounds
-
85% success Force unlock the state: terraform force-unlock LOCK_ID
Force unlock the state: terraform force-unlock LOCK_ID
-
95% success Manually delete the lock item from DynamoDB table using AWS CLI: aws dynamodb delete-item --table-name terraform-locks --key '{"LockID": {"S": "<state-file-path>"}}'
Manually delete the lock item from DynamoDB table using AWS CLI: aws dynamodb delete-item --table-name terraform-locks --key '{"LockID": {"S": "<state-file-path>"}}'
中文步骤
Force unlock the state: terraform force-unlock LOCK_ID
Manually delete the lock item from DynamoDB table using AWS CLI: aws dynamodb delete-item --table-name terraform-locks --key '{"LockID": {"S": "<state-file-path>"}}'
Dead Ends
Common approaches that don't work:
-
70% fail
Deleting the table loses all lock metadata and may cause state corruption if another process is actively using it.
-
90% fail
Disabling locks risks concurrent writes and state corruption. Only safe for one-off operations.