Estimated reading time: 1 min read

Terraform uses a lock on backends that support locking to coordinate operations on shared state. The lock prevents concurrent writers from working against the same state snapshot.

Coordinating changes to shared state

Terraform uses state to track the resources it manages. Operations that could write state acquire a lock when the backend supports it. If a lock is held, inspect the existing operation before retrying or intervening.

Finding the owner

Use lock details such as the ID, operation, owner, and creation time to locate the corresponding process or automation run. Check the run’s status and confirm there is no active Terraform process for that state. The timestamp alone cannot tell you whether the operation is still running.

Recovering an orphaned lock

Use terraform force-unlock with the reported lock ID only after confirming your operation left the lock behind and can no longer release it. The command releases the lock and does not change infrastructure. Run a fresh plan with normal locking to check current state and intended changes before applying.

All fundamentals