Your team uses a remote S3 backend with DynamoDB locking. A colleague ran `terraform apply` but it failed mid-way. The lock was NOT automatically released. What is the safest first step?

Direct Answer (Verified)Reviewed by Sunny (Senior Cloud Engineer)

Correct Answer: Run `terraform force-unlock <LOCK_ID>` after confirming no other apply is running

`terraform force-unlock <LOCK_ID>` safely releases a stuck lock. You must first confirm no concurrent operation is genuinely running, as forcing an unlock while another operation i...

Real Exam Scenario

Your team uses a remote S3 backend with DynamoDB locking. A colleague ran `terraform apply` but it failed mid-way. The lock was NOT automatically released. What is the safest first step?

✓ Correct Answer & Explanation

Correct Answer

Run `terraform force-unlock <LOCK_ID>` after confirming no other apply is running

Why This Answer Is Correct

`terraform force-unlock <LOCK_ID>` safely releases a stuck lock. You must first confirm no concurrent operation is genuinely running, as forcing an unlock while another operation is active can corrupt state. Deleting the DynamoDB entry manually bypasses Terraform's safety checks. Never delete the state file — it's the source of truth for your infrastructure.