Prompt
Why are my Terraform applies failing because of state lock issues?
Latest observation
Oct 5, 2026
OpenAI APIWeb search: off
Terraform apply failures due to state lock issues usually mean Terraform thinks someone else is already modifying the same state, or it can’t properly create/release the lock. Common causes:
Typical reasons
-
Another Terraform run is in progress
- Someone else is running
terraform apply/plan. - A CI job is still active.
- A previous run crashed but left the lock behind.
- Someone else is running
-
Stale lock from an interrupted run
- Terraform exited unexpectedly.
- Network interruption happened while using a remote backend.
-
Remote backend locking problems
- S3 + DynamoDB lock table misconfiguration.
- AzureRM backend storage access issues.
- GCS/remote backend permissions or connectivity problems.
-
Permissions or API errors
- Your credentials can read state but can’t write or update the lock record.
- Backend service throttling or transient API failures.
-
Using the wrong workspace/state
- Multiple pipelines or branches are accidentally targeting the same backend state.
What the error usually looks like
You’ll often see messages like:
Error acquiring the state lockresource temporarily unavailableConditionalCheckFailedException- lock info showing another operation
How to fix it safely
-
Check whether another Terraform operation is running
- In CI/CD, confirm there isn’t a parallel job.
- Ask teammates whether someone is applying right now.
-
Inspect the lock information
- Terraform often prints who holds the lock and when.
- Use that to determine if it’s stale.
-
Release stale locks carefully
- If you’re sure no other apply is running, remove the lock using the backend-appropriate method.
- For example, with some backends:
terraform force-unlock LOCK_ID
- Only do this if you’re certain the lock is stale.
-
Fix backend configuration
- Verify state backend credentials, permissions, and lock table/storage settings.
- Ensure all automation uses the same backend config consistently.
-
Avoid concurrent runs
- Serialize Terraform in CI.
- Use one pipeline per state, or separate states/workspaces.
Practical next steps
- Re-run with
TF_LOG=INFOorTF_LOG=DEBUGto see lock details. - Confirm no other apply is active.
- If the lock is stale and you’re certain, use
terraform force-unlock. - If it keeps happening, review backend locking setup and CI concurrency.
If you want, paste the exact error message and your backend type (S3, AzureRM, GCS, Terraform Cloud, etc.), and I can tell you the most likely cause and exact fix.