In one sentence
A good module encapsulates a stable decision and lets the root module compose the architecture.
Premature abstraction is expensive
A module built for every project accumulates flags, conditionals and confusing outputs. It is reusable in theory and risky to change in practice.
A structure that usually works
- Root modules by environment or system: compose resources and deployment decisions.
- Small modules: encapsulate repeated patterns with one responsibility.
- Pinned versions: prevent unreviewed shared changes.
- Plans in pull requests: expose impact before apply.
What should not become a variable
If an option breaks the security model or creates a different architecture, it likely deserves another module. Useful flexibility keeps contracts clear.
Refactor without stopping production
Stabilize providers, state and pipelines first. Then extract modules without recreating resources, using reviewable plans and small changes.