Terraform & IaC (50 Qs)•Part 4: Enterprise Cloud Infrastructure Architecture & SRE (35 - 50)
How do you handle State Lock Deadlocks in Terraform (`force-unlock`)?
senior LevelCode ExampleFormsCI/CD & DevOpsSystem Design
In Simple Words: If an apply command is killed prematurely (e.g. network failure, laptop lid closed), DynamoDB retains the lock, blocking future applies:
bash
# Output provides Lock ID: e.g. "b3e028b1-1249-..."
terraform force-unlock b3e028b1-1249-...
Caution: Never force-unlock while another team member or CI/CD job is actively executing!