Inputs, defaults, and validation
A module interface should expose choices callers genuinely need while retaining safe defaults. Validate meaningful constraints and explain units. Too many unrelated toggles make behavior difficult to reason about; too few inputs force callers to copy and modify the module. For example, a network module accepts CIDR and availability-zone choices, validates CIDR syntax, and describes subnet allocation expectations.
A network module accepts CIDR and availability-zone choices, validates CIDR syntax, and describes subnet allocation expectations.
A module author considers exposing thirty flags. Instead, start with the caller's real decisions: address space, environment name, required capacity, and supported exposure policy. Supply safe defaults for choices not normally made by callers, then validate constraints and document exceptions. Inputs should communicate intent rather than reproduce every provider attribute indiscriminately.
An input contract defines accepted values and meaning. Validation catches selected unacceptable combinations or values. A default is a deliberate fallback, not an excuse to omit documentation. Too many controls create a combinatorial testing burden; too few may force teams to fork the module. Include units, null behavior, and whether a change causes replacement. A reusable module cannot guarantee suitability for every organization. State its supported scope and provide examples that demonstrate actual assumptions, including cost and permissions, so callers can review the resulting resources rather than trust the package name.
A network module accepts CIDR and availability-zone choices, validates CIDR syntax, and describes subnet allocation expectations.
Do not overlook this operational distinction: Too many unrelated toggles make behavior difficult to reason about; too few inputs force callers to copy and modify the module.