Terragrunt "Error acquiring the state lock" during run-all in CI
A run-all executes many units concurrently. If two units share a state, or a previous killed job left a DynamoDB lock behind, Terraform cannot acquire the state lock and the run fails. Terragrunt runs distinct units in parallel, so contention is a run-all-specific pitfall.
What this error means
A run-all apply fails with "Error acquiring the state lock" and a Lock Info block showing an existing lock ID, often from a job that was cancelled mid-run.
Error: Error acquiring the state lock
Error message: operation error DynamoDB: PutItem, ConditionalCheckFailedException:
the conditional request failed
Lock Info:
ID: 7f3c9a12-...
Operation: OperationTypeApply
Created: 2026-06-30 10:12:03 UTCCommon causes
A stale lock from a cancelled job
A prior run was cancelled or the runner was killed before releasing the lock, so the DynamoDB lock row persists and blocks the next run.
Two units contend for the same state
A misconfigured backend key gives two run-all units the same state path, so their parallel apply fights over one lock.
How to fix it
Release a confirmed-stale lock
- Confirm no other job is actually running against that state.
- Release the lock with
force-unlockusing the reported lock ID. - Re-run the pipeline.
terragrunt force-unlock 7f3c9a12-... --terragrunt-working-dir live/prod/vpcGive each unit a unique state key
Derive the backend key from the module path so no two units share state.
key = "${path_relative_to_include()}/terraform.tfstate"How to prevent it
- Use
path_relative_to_include()so every unit has a distinct state. - Avoid cancelling jobs mid-apply; let them release the lock.
- Lower
--terragrunt-parallelismif lock contention is frequent.