HomeSoftware Engineering Error buying the state lock in Terraform

[Solved] Error buying the state lock in Terraform

In case you have been handed the Buying state lock error message about ConditionalCheckFailedException: The conditional request then you could have 2 choices for fixing it!

The error appears to be like one thing like this:

Buying state lock. This will take a number of moments...
│ Error: Error buying the state lock
│ Error message: ConditionalCheckFailedException: The conditional request
│ failed
│ Lock Data:
│   ID:        3324a6cb-7401-3194-d650-fxxxxxx3864
│   Path:      xxxx-terraformstate-nonprod/env:/xxxx/terraform.tfstate
│   Operation: OperationTypeApply
│   Who:       [email protected]
│   Model:   1.0.4
│   Created:   2021-11-29 21:00:37.652114035 +0000 UTC
│   Data:
│ Terraform acquires a state lock to guard the state from being written
│ by a number of customers on the identical time. Please resolve the difficulty above and check out
│ once more. For many instructions, you may disable locking with the "-lock=false"
│ flag, however this isn't advisable.

There are 3 potential methods to repair this

In brief, you wish to delete the lock related. That is achieved by forcing an unlock.

You’ll be able to power unlock the state utilizing the next:

terraform force-unlock -force 3324a6cb-7401-3194-d650-fxxxxxx3864

Choice 2: Relaunch the Plan

You’ll be able to run the plan once more with a -lock=false as following:

terraform plan -lock=false ...

Choice 3: Be sure to use the correct profile!

Typically all the pieces appears appropriate, however it seems you’re utilizing a special profile!


Power Unlock nonetheless not working?

Typically you may get one other error when making an attempt to power unlock this:
Didn't unlock state: didn't retrieve lock data: surprising finish of JSON enter

This often means that you’re within the fallacious workspace.

View all workspaces obtainable: terraform workspace record

Change to a workspace: terraform workspace choose <>

Now you may attempt to power unlock once more.

If you happen to have been profitable, then you’re going to get the next message:

Terraform state has been efficiently unlocked!

The state has been unlocked, and Terraform instructions ought to now have the ability to
receive a brand new lock on the distant state.

Most Popular

Recent Comments