Interview Prep/Terraform/Partial Applies, Version Mismatches and CI Failures

Pull request plans fail with `Error: Error acquiring the state lock` whenever two PRs touch the same stack.

IntermediateTroubleshootingPartial Applies, Version Mismatches and CI Failures
Answer

Likely causes → Plans take the state lock too (to read a consistent snapshot); two concurrent PR plans collide.

Diagnose → Pipeline logs show overlapping plan runs on the same key.

Fix → Retry with a lock timeout: terraform plan -lock-timeout=5m. For PR plans, -lock=false is acceptable only for read-only speculative plans that are never applied.

Prevent → Concurrency groups per stack in CI; HCP Terraform/Atlantis queue runs automatically.

All Terraform questions

More on Partial Applies, Version Mismatches and CI Failures