General Explanation
Terraform modules across environments
Principles for designing reusable Terraform modules that keep production, UAT and development consistent.
General principles for a setup like the one in the Symbl case study, where reusable modules standardize seven to eight environments.
One shape, different inputs
An environment should differ from another by its inputs (sizes, counts, names), not by its structure. If production has a resource that UAT lacks, that difference should be a deliberate variable, not an accident.
Keep modules small and opinionated
A module that wraps a network, a service and its alarms together is easy to reuse. A module that exposes every provider argument is just the provider with extra steps.
Separate state per environment
A mistake in development should not be able to touch production. Separate state, and separate credentials where possible, limit how far a change can reach.
Watch for drift
Modules reduce drift but do not prevent console changes. Review plan output, and treat unexpected diffs as something to investigate, not apply.
Version the modules
When a module changes, roll the change through development and UAT before production, so the shared code is exercised before it matters.