Skip to content

Instantly share code, notes, and snippets.

@rodrigo-galba
Created June 14, 2021 21:34
Show Gist options
  • Select an option

  • Save rodrigo-galba/cf31777b718ecaa85d02708d3a9eb2ff to your computer and use it in GitHub Desktop.

Select an option

Save rodrigo-galba/cf31777b718ecaa85d02708d3a9eb2ff to your computer and use it in GitHub Desktop.
Terraform: Get LOCK id

How to get the lock ID for terraform?

I need to force a unlock, but how to get the lock id?

$ terraform destroy
Acquiring state lock. This may take a few moments...

Error: Error locking state: Error acquiring the state lock: 2 error(s) occurred:

* storage: service returned error: StatusCode=409, ErrorCode=LeaseAlreadyPresent, ErrorMessage=There is already a lease present.
**RequestId:132435b7-101e-004b-552e-b732a8000000**
Time:2018-03-08T22:41:18.7452012Z, RequestInitiated=Thu, 08 Mar 2018 22:41:18 GMT, RequestId=132435b7-101e-004b-552e-b732a8000000, API Version=2016-05-31, QueryParameterName=, QueryParameterValue=
* blob metadata "terraformlockid" was empty

Terraform acquires a state lock to protect the state from being written
by multiple users at the same time. Please resolve the issue above and try
again. For most commands, you can disable locking with the "-lock=false"
flag, but this is not recommended.
~> terraform force-unlock 132435b7-101e-004b-552e-b732a8000000
Do you really want to force-unlock?
  Terraform will remove the lock on the remote state.
  This will allow local Terraform commands to modify this state, even though it
  may be still be in use. Only 'yes' will be accepted to confirm.

  Enter a value: yes

Failed to unlock state: failed to retrieve lock info: blob metadata "terraformlockid" was empty

Except from gitmemoty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment