Composition versus deeply nested modules: which is better?
IntermediateConceptModules
Answer
Composition. A flat root that calls small modules and wires outputs to inputs is easy to read and test. Deep nesting (module calling module calling module) hides resources, makes passing providers painful, and amplifies breaking changes. We stay at one or two levels.
More on Modules
What is a Terraform module and why use one?BeginnerHow do you call a module?BeginnerHow do inputs and outputs work with modules?BeginnerWhich module source types exist and where does `version` apply?IntermediateHow should you version and pin modules?IntermediateCan you use `count` and `for_each` on modules?Intermediate