Module structure and interfaces
A module groups configuration under a directory and presents inputs and outputs. The root module calls child modules. Avoid hiding all configuration behind many trivial modules; boundaries should reflect reusable responsibility with clear validation, versioning, and documentation. For example, modules/network accepts a CIDR and returns vpc_id and subnet IDs for callers.
modules/network accepts a CIDR and returns vpc_id and subnet IDs for callers.
Split a learning stack into a network module, a compute module, and a storage module only when each has a clear responsibility. The root module supplies environment inputs, passes network outputs into compute, and exposes a small set of useful results. The modules are configuration directories, not independently running services.
A root module is the configuration where Terraform starts. A child module is called through a module block. An interface consists of inputs and outputs. Define ownership before reuse: two callers must not both manage the same shared bucket unintentionally. Avoid modules that simply wrap one setting without adding meaningful policy or interface value. Larger modules can encode useful defaults but may hide cost or permissions, so inspect their resources and versions. Document prerequisites and expected changes. A modular project is easier to compose only when its interfaces make dependencies clearer rather than conceal them.
modules/network accepts a CIDR and returns vpc_id and subnet IDs for callers.
Do not overlook this operational distinction: Avoid hiding all configuration behind many trivial modules; boundaries should reflect reusable responsibility with clear validation, versioning, and documentation.