Interview Prep/Terraform/CI/CD and Automation

How do you serialize applies to the same stack in CI?

AdvancedProductionCI/CD and Automation
Answer

Use a concurrency group keyed by stack so only one run per stack executes and later ones queue (do not cancel an in-progress apply).

concurrency:
  group: tf-${{ matrix.stack }}
  cancel-in-progress: false

Add -lock-timeout as a second layer. Never enable cancel-in-progress for apply jobs: killing Terraform mid-apply leaves locks and partial state.

All Terraform questions Roadmap: Terraform in production

More on CI/CD and Automation