Platform team wants each module tested before release. What's your approach?
IntermediateScenarioModules and Code Structure
Answer
Situation read → Modules are shared dependencies and need a test gate.
What I'd do →
- Static:
fmt,validate,tflint,checkovon every PR. - Plan-level tests with
terraform testusingcommand = planand mock providers. - Integration tests in a sandbox account for critical modules, applying and destroying.
- Run the examples folder in CI.
Why → Cheap checks run on every commit; expensive real-cloud tests run before release.
Interview tip → Mention cleanup: tag test resources and run a sweeper so failed runs don't leak cost.
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?IntermediateHow do you release a shared module so consumers can upgrade at their own pace?IntermediateA module needs to deploy to a second region. Why does putting a provider block inside the module cause trouble?Advanced