Skip to main content

Stage 5: Refactor Root Modules

Developers recognize the pitfalls of having all environments in one root module. After having refactored their code heavily into modules, Developers realized it was a bad idea to define dev, staging and prod, all in the same root module. Developers realize terraform gets very slow and brittle when a root module is too large.

  1. Initiate the split of the monolithic root module into smaller, more manageable units while incorporating additional feature flags and expanding configuration management through .tfvars files.
  2. Move towards a structure where multiple root modules are used, each one precisely aligned with specific environments to enhance maintainability and performance.
  3. Recognize the efficiency gains and increased adaptability that came from segregating large root modules, leading to quicker Terraform operations and easier adjustments per environment.
New Problems
  1. Increased feature flags and configuration management using .tfvars.
  2. Performance becomes a concern with overly large root modules.
  3. Very poor reusability across the organization due to the "snowflake" nature of the root modules.

Realization

After refactoring to smaller "root modules", now there are some dependencies between them, including shared configurations that were once easily passed between resources, but are now variable inputs.

Developers hate repeating themselves, so attention shifts to DRY Configuration.

Try Atmos!