githubEdit

How to release a stale Terraform state lock

If you encounter a Terraform state lock that appears to be stuck or stale, you can safely release it after confirming no active operations are running. Before releasing the lock Always verify that no Terraform apply or other operations are currently running for the affected path. Releasing a lock while an operation is active can cause state corruption. Releasing the lock Once you've confirmed no operations are running, you can release the lock using the following command: terraform force-unlock [LOCK_ID] Replace [LOCK_ID] with the actual lock ID from your error message. The lock ID can be found in the lock information, typically in the "ID" field of the lock details. Example If your lock ID is 8e1bddb3-524b-ac81-4ca9-0b7608ef9ddd , you would run: terraform force-unlock 8e1bddb3-524b-ac81-4ca9-0b7608ef9ddd Warning: Only use terraform force-unlock when you are certain no Terraform operations are running. Using this command while an operation is active can corrupt your Terraform state.

Last updated

Was this helpful?