# 获取状态锁失败：ConditionalCheckFailedException：条件请求失败

- **ID:** `terraform/state-lock-dynamodb-conditional-check-failed`
- **领域:** terraform
- **类别:** resource_error
- **错误码:** `ConditionalCheckFailedException`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

DynamoDB 状态锁表的条件表达式失败，通常是因为另一个进程持有锁或锁记录已过期。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Terraform 1.5 | active | — | — |
| Terraform 1.6 | active | — | — |
| Terraform 1.7 | active | — | — |
| AWS Provider 5.0+ | active | — | — |

## 解决方案

1. ```
   Force unlock the state: terraform force-unlock LOCK_ID
   ```
2. ```
   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>"}}'
   ```

## 无效尝试

- **** — Deleting the table loses all lock metadata and may cause state corruption if another process is actively using it. (70% 失败率)
- **** — Disabling locks risks concurrent writes and state corruption. Only safe for one-off operations. (90% 失败率)
