Sphere
Log in Join
☆ 5

terraform apply stuck on error acquiring the state lock

Killed a terraform apply halfway through with Ctrl+C and now every plan dies. Terraform 1.6.6 with an S3 backend and a DynamoDB lock table. Error says Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed and prints a Lock Info block with an ID and Operation: OperationTypeApply. The apply was modifying an RDS instance at the time, so I'm nervous about just force-unlocking. What's the safest way out here?

⚑ Report

4 replies

☆ 0
M mossy ·2026-09-20#1

First check whether the apply actually finished. Read the lock info's Info field for the PID and time, and look at the RDS instance in the console. If the change completed, the state may have been written before the lock got stuck. If it didn't, you want to let the remaining plan apply rather than discard anything.

⚑ Report
☆ 0
B blame ·2026-09-28#2

RDS shows the new parameter group attached, so most of it went through. The apply output stopped right before the last step which was a security group rule. I can't tell if that rule exists. terraform plan is blocked by the lock so I can't check diffs.

⚑ Report
☆ 0
C clip ·2026-09-29#3

That lock is stale, not a real concurrent operation. DynamoDB locks don't auto-expire in older setups, so a Ctrl+C leaves them forever. You can verify no other apply is running by checking who else has the state file open, then terraform force-unlock with the ID from the error. It only removes the lock row, it doesn't touch state.

⚑ Report
☆ 0
Z zombie ·2026-10-13#4

After unlocking, run terraform plan and look at the security group rule specifically. If it's missing, apply again and Terraform will add it. If it's there, you're done. And switch the backend to S3 native locking with use_lockfile if your provider supports it, that one expires properly.

⚑ Report
Log in to reply.