How do you release a shared module so consumers can upgrade at their own pace?
IntermediateScenarioModules and Code Structure
Answer
Situation read → Many stacks depend on one module, and a breaking change must not hit them all at once.
What I'd do →
- Keep modules in their own repo (or path with tags) and release with SemVer tags:
v1.4.0. - Consumers pin:
source = "git::https://github.com/acme/tf-modules.git//vpc?ref=v1.4.0". - Maintain a CHANGELOG and flag breaking changes with a major bump and migration notes (and
movedblocks).
Why → Pinned versions mean consumers upgrade when ready, and moved blocks shipped inside the module make renames painless.
Interview tip → Branch references like ref=main are a production incident waiting to happen.
More on Modules and Code Structure
When do you turn a block of resources into a module, and when do you leave it alone?BeginnerHow do you consume a community module like `terraform-aws-modules/vpc/aws` responsibly?BeginnerAn ECS service module needs the VPC and subnets created by a network module. How do you wire them together?IntermediateHow would you lay out a repo that deploys the same stack to dev, stage and prod?IntermediateA module needs to deploy to a second region. Why does putting a provider block inside the module cause trouble?AdvancedTeams complain a "VPC module" has 90 variables and still doesn't do what they need. How do you fix the design?Intermediate