Chapter Nine

Organizing Larger Codebases

How a single directory grows into a repository that a team can navigate, with state boundaries that match blast radius and environments that isolate production instead of sharing its fate.

5 topics

A configuration that fits in one directory needs no organization. The trouble starts when it does not: a single state covering an entire estate, plans that take minutes, an apply that risks everything, and a directory tree where reusable modules and the things you actually run are mixed into one pile nobody can read. This chapter is about the layout decisions that keep that from happening.

The recurring tension is DRY versus isolation. Removing duplication is good until the abstraction that removes it is harder to operate than the copy-paste it replaced — and isolating production from dev is worth a little duplication. These five topics cover repository layout, the workspaces-versus-directories decision, the split between root and shared modules, the DRY patterns that are worth it, and the honest case for reaching for Terragrunt.

Topics in This Chapter