Azure backend fails force-unlock - There is already a lease present

2,044 views
Skip to first unread message

Brian Moritz

unread,
Dec 12, 2017, 11:24:53 AM12/12/17
to Terraform
I had a long running TF apply and our proxy timed out and I lost connection and my state is still locked. I'm using Azure storage for the backend and running a force-unlock ID only tells me that there is a lease present, it doesn't actually release the lease.
Any advice on how to unlock the state is appreciated.

Terraform v0.11.1
+ provider.azurerm v0.3.3


./>terraform force-unlock ID
Failed to load state: failed to lock azure state: storage: service returned error: StatusCode=409, ErrorCode=LeaseAlreadyPresent, ErrorMessage=There is already a lease present.
RequestId:000000-000000-0000000
Time:2017-12, RequestInitiated=.... RequestId=000000-000000-0000000, API Version=2016-05-31, QueryParameterName=, QueryParameterValue=
Lock Info:
  ID:        000000-000000-0000000
  Path:      path/to/azure/backend/state
  Operation: OperationTypeApply
  Who:       me
  Version:   0.11.1
  Created:   2017-12-11

Brian Moritz

unread,
Dec 12, 2017, 1:04:26 PM12/12/17
to Terraform
I was able to release the lock by following this post:

That put the blob in a broken lease state, then I was able to edit the metadata in the Azure portal and delete the lease. You might be able to do that from the portal initially but it was the 2nd step I did so not completely sure. Just wanted to share because I have seen other posts on this. The force-unlock doesn't seem to work with an Azure backend.
Reply all
Reply to author
Forward
0 new messages