Command Palette

Quick search articles, topics, and actions

Snippet.
hcl11 lines
H A R S H H A A

Force-unlock a stuck Terraform state lock

When a teammate's CI dies mid-apply and the state lock outlives it.

Source.
hcl
# 1. Identify the lock ID from the error output
terraform plan -lock-timeout=5s

# 2. Inspect who holds it (S3 backend + DynamoDB)
aws dynamodb get-item --table-name terraform-locks --key '{"LockID":{"S":"my-org/prod/tfstate"}}'

# 3. Force-unlock — only after confirming nobody is applying
terraform force-unlock <LOCK_ID>

# Local state surgery fallback:
terraform force-unlock -force <LOCK_ID>
Zero-friction retrieval.
Pipe it straight into your shell
$ curl -fsSL https://blog.harshhaareddy.com/raw/wpbb207wrvb7m6lbtmabs3at

Fetches the raw snippet — review it, then redirect or pipe it however you like.