Where should you document modules so people actually use them correctly?
BeginnerScenarioModules and Code Structure
Answer
Situation read → Undocumented modules get copied and forked.
What I'd do →
- Add a README per module with purpose, an example call and inputs/outputs.
- Generate the tables with
terraform-docsvia pre-commit so they never go stale. - Include an
examples/basicdirectory that CI actually plans.
terraform-docs markdown table --output-file README.md --output-mode inject ./modules/vpc
Why → Generated docs match the code; tested examples prove the README works.
Interview tip → Also write descriptions on every variable and output.
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