What it means
Terraform and OpenTofu lock the state during plan and apply so two runs can't corrupt it. The error shows who holds the lock and since when. If a run is still going, wait; if one crashed, the lock is stale.
Causes and fixes
Most likely first. Run the check, and if it matches, apply the fix.
1. Another plan or apply is running (a CI job, a colleague)
Check:
Read the Who and Created fields in the error
Fix: Wait for it to finish; add CI concurrency so only one runs per state.
2. A crashed or cancelled run left the lock
Check:
Confirm nothing is running anymore
Fix: terraform force-unlock <LOCK_ID>, only once you're sure.
Fix it yourself
A live machine in your browser with this problem already on it. The grader checks the result.
- Move the State Out of the Repositorymedium 9 min
- Apply Only What Was Reviewedmedium 8 min
- Cancel Outdated CI Runsmedium 8 min
No account needed for your first tries.
Related errors
- Error: creating ...: already exists
The real resource exists but isn't in the state, so Terraform tries to create it again.