ConditionalCheckFailedException
terraform
resource_error
ai_generated
true
获取状态锁失败:ConditionalCheckFailedException:条件请求失败
Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed: The conditional request failed
ID: terraform/state-lock-dynamodb-conditional-check-failed
90%修复率
85%置信度
1证据数
2023-05-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Terraform 1.5 | active | — | — | — |
| Terraform 1.6 | active | — | — | — |
| Terraform 1.7 | active | — | — | — |
| AWS Provider 5.0+ | active | — | — | — |
根因分析
DynamoDB 状态锁表的条件表达式失败,通常是因为另一个进程持有锁或锁记录已过期。
English
DynamoDB state lock table's condition expression failed, typically because another process holds the lock or the lock record is stale.
官方文档
https://developer.hashicorp.com/terraform/language/state/locking解决方案
-
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>"}}'
无效尝试
常见但无效的做法:
-
70% 失败
Deleting the table loses all lock metadata and may cause state corruption if another process is actively using it.
-
90% 失败
Disabling locks risks concurrent writes and state corruption. Only safe for one-off operations.