# Error: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed

- **ID:** `cicd/terraform-state-lock-error`
- **Domain:** cicd
- **Category:** resource_error
- **Error Code:** `ConditionalCheckFailedException`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

Terraform failed to acquire the state lock in DynamoDB because another process holds the lock, or the lock item has been modified by a concurrent operation.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Terraform 1.5.0 | active | — | — |
| AWS Provider 5.10.0 | active | — | — |
| DynamoDB | active | — | — |

## Workarounds

1. **Identify the lock holder by checking DynamoDB table: aws dynamodb get-item --table-name <lock_table> --key '{"LockID": {"S": "<state_path>"}}'. If the lock is stale, use terraform force-unlock <lock_id> after manual verification.** (95% success)
   ```
   Identify the lock holder by checking DynamoDB table: aws dynamodb get-item --table-name <lock_table> --key '{"LockID": {"S": "<state_path>"}}'. If the lock is stale, use terraform force-unlock <lock_id> after manual verification.
   ```
2. **If the lock is held by a crashed process, wait for the lock timeout (default 15 minutes) and retry, or increase the lock timeout in the backend config.** (80% success)
   ```
   If the lock is held by a crashed process, wait for the lock timeout (default 15 minutes) and retry, or increase the lock timeout in the backend config.
   ```

## Dead Ends

- **** — Force-unlocking without verifying who holds the lock can corrupt state or cause data loss. (30% fail)
- **** — Deleting the DynamoDB lock table removes all locks but also breaks state locking for future operations. (10% fail)
