A sort thing to write
TL;DR
Using force-unlock command
## terraform force-unlock [options] LOCK_ID
## Example
$ terraform force-unlock 49b6e22e-XXXX-XXXX-XXXX-3e3097cf95d4
The lock ID shows in the error message
The story
Your terraform using S3 as backend like this
backend "s3" {
bucket = "terraform-state-bucket"
key = "env/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "db-terraform-lock-state"
}
Error acquiring the state lock when sudden cancel command like terraform plan
After repeat command or action related to acquiring lock. The error message will show:
Error message: operation error DynamoDB: PutItem, https response error StatusCode: 400, RequestID: XXXX, ConditionalCheckFailedException: The conditional request failed
Now I see where I’m stuck on, and gap the lock ID, in this case I’m sure that I’m the only one who is doing this task with terraform S3 backend without conflict with others.
$ terraform force-unlock 49b6e22e-XXXX-XXXX-XXXX-3e3097cf95d4
The result
That’s all. Thanks!