terraform
resource_error
ai_generated
true
Error: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed: The conditional request failed
ID: terraform/terraform-state-lock-unlock-failed
85%Fix Rate
85%Confidence
1Evidence
2023-08-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Terraform v1.6 | active | — | — | — |
| Terraform v1.7 | active | — | — | — |
| Terraform v1.8 | active | — | — | — |
| AWS Provider v5.0+ | active | — | — | — |
Root Cause
Another Terraform process holds the state lock, or a previous lock was not released properly.
generic中文
另一个 Terraform 进程持有状态锁,或之前的锁未正确释放。
Official Documentation
https://developer.hashicorp.com/terraform/language/state/lockingWorkarounds
-
80% success Force unlock the state using 'terraform force-unlock <lock_id>' after verifying no other Terraform process is running. First, run 'terraform plan' to see if the lock is stale.
Force unlock the state using 'terraform force-unlock <lock_id>' after verifying no other Terraform process is running. First, run 'terraform plan' to see if the lock is stale.
-
90% success If using S3 backend, manually delete the lock file from the DynamoDB table using AWS CLI: 'aws dynamodb delete-item --table-name <table-name> --key {"LockID":{"S":"<lock-id>"}}'
If using S3 backend, manually delete the lock file from the DynamoDB table using AWS CLI: 'aws dynamodb delete-item --table-name <table-name> --key {"LockID":{"S":"<lock-id>"}}'
中文步骤
Force unlock the state using 'terraform force-unlock <lock_id>' after verifying no other Terraform process is running. First, run 'terraform plan' to see if the lock is stale.
If using S3 backend, manually delete the lock file from the DynamoDB table using AWS CLI: 'aws dynamodb delete-item --table-name <table-name> --key {"LockID":{"S":"<lock-id>"}}'
Dead Ends
Common approaches that don't work:
-
70% fail
Deleting the lock file can corrupt state if another process is still running, leading to state conflicts.
-
50% fail
Using a wrong lock ID will not release the lock, and may cause additional errors if the lock is actually held by a different process.
-
60% fail
The lock may still be held by the previous process, and restarting will not release it automatically.