AWS Builder Center

Error acquiring the state lock

Fix to Unlock a terraform state file with error - Error acquiring the state lock

Series: AWS and Terraform (4 articles)

  1. 2
    Error acquiring the state lock This article
In this article I want to share a fix for the issue we faced in Terraform.
I am using s3 as my backend, with a DynamoDB table for state locking. When I try to run a plan, I am getting a message: Error: Error acquiring the state lock. We got Lock Info and its ID details as shown below:
│ Lock Info:
│ ID: 1609e181-bc9b-f8e4-83d1-1aba972977de
we scanned the DynamoDB in which state lock is maintained. Listed the items in the DynamoDB and identified the item with lock info same as the id mentioned in our error. We deleted the item in DynamoDB. Once deleted the Terraform state lock issue got resolved.
This is not a best practise. It has to be performed in caution after analysis and exception approval in case we cannot unlock the terraform state file using terraform force-unlock command.

Series: AWS and Terraform (4 articles)

  1. 2
    Error acquiring the state lock This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article