Search code examples
terraformterraform-provider-azure

Error locking state: Error acquiring the state lock: state blob is already locked


I am getting this error when I try to do any operation:

Error locking state: Error acquiring the state lock: state blob is already locked

How can I list the people currently have a lock and how long the lock has been acquired for?


Solution

  • The easiest fix for this issue is to:

    (1) navigate to the storage account,

    (2) then to the container in the Azure portal that holds the state file.

    (3) The blob will show as ‘Leased’ under the leased state column.

    (4) Select the state file, and hit the ‘break lease’ button.

    *FYI: You need PIM (Privileged Identity Management (PIM)) to do this.

    Quote from Fixing Terraform ‘Error acquiring state lock’ in Azure

    enter image description here