In a monorepo with 40 stacks, how do you plan only the stacks that changed?
AdvancedScenarioPipelines Terraform Cloud and OpenTofu
Answer
Situation read → Planning everything on every PR is slow and noisy.
What I'd do →
- Detect changed paths (
git diff --name-only origin/main...HEAD) or usepaths:filters. - Map changed module directories to the stacks that use them.
- Generate a job matrix of affected stacks and run plans in parallel.
- Apply in dependency order (network before apps).
Why → Affected-only plans scale; a shared module change correctly fans out to all consumers.
Interview tip → Shared module changes are the case naive path filters miss.
More on Pipelines Terraform Cloud and OpenTofu
Build a basic GitHub Actions pipeline: plan on pull request, apply on merge to main.BeginnerReviewers can't read raw plan logs. How do you present the plan in the PR?IntermediateTwo PRs merge close together and both apply to the same stack. What prevents trouble?IntermediateHow do you add a manual approval before prod applies?IntermediateCompare Atlantis, HCP Terraform and a hand-built GitHub Actions pipeline.IntermediateA saved plan was approved yesterday and apply fails because main changed. How do you avoid dead approvals?Intermediate