Terraform: Error locking state

If you have Terraform state locks. Sometimes cancelling terraform commands ungracefully might leave the state file locked. This is the error you would usually see if the lock is not released.

nn

Acquiring state lock. This may take a few moments...nnError: Error locking state: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failedn status code: 400, request id: L2CH7KK3QCAEHSC1TJ1VLBMNBRVV4CQNSO5AEMVJY66Q9ASUAAJNnLock Info:n  ID:        21e2b2bb-c123-2383-eece-7a5eaab4f645n  Path:      s3/path/to/the/state/filen  Operation: OperationTypePlann  Who:       username@hostnamen  Version:   0.11.14n  Created:   2020-02-11 11:26:58.602608 +0000 UTCn  Info:nnnTerraform acquires a state lock to protect the state from being writtennby multiple users at the same time. Please resolve the issue above and trynagain. For most commands, you can disable locking with the "-lock=false"nflag, but this is not recommended.n

nn

If you want to release this lock. You should run below command. Then type “yes” and hit enter.

nn

$ terraform force-unlock <LOCK ID>n

nn

For example:

nn

$ terraform force-unlock 21e2b2bb-c123-2383-eece-7a5eaab4f645n

nn

screenshot

nn

n

Warning: Please don’t release this lock, unless you are the once who caused it. It might corrupt the state file.

n

nn

Gists

nn

nn

Tags

nn

    n

  • aws
  • n

  • terraform
  • n

n

Proudly powered by WordPress

Discover more from Dedunu

Subscribe now to keep reading and get access to the full archive.

Continue reading