liveBook · Manning

Monolithic architecture

As explained in Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform

An infrastructure-as-code organization pattern in which all infrastructure resources are defined in one tightly coupled configuration.

Monolithic architecture defines all infrastructure resources in one tightly coupled configuration and the same state. As the configuration grows, changes to one resource can create conflicts, slow deployments, and make isolated changes difficult. A single repository is not necessarily monolithic when separate directories contain independent infrastructure configurations. section 10.2

Refactor the monolith incrementally:

  • Identify high-level resources with no dependencies, such as project-level IAM roles and service accounts. section 10.2.1
  • Copy their configuration into a separate directory or repository, initialize separate state, and import the existing resources. section 10.2.1
  • Deploy and inspect the plan to confirm that the live infrastructure remains unchanged before removing the resources from the monolith. section 10.2.1
  • Extract dependent resources next, replacing direct references with dependency injection through the infrastructure provider API. section 10.2.2
  • Repeat the process toward the lowest-level resources, isolating components and testing each change to limit disruption. section 10.2.3

Extracting GCP IAM resources

A team separates project-level IAM roles and service accounts from a large configuration by copying the code, importing existing resources into new state, verifying a no-change plan, and removing the IAM resources from the monolith. The same approach later extracts a container orchestrator, which retrieves network and subnet identifiers through the GCP API. section 10.2.1 section 10.2.2

Figure 10.5 The sundew system’s IAM policies for the GCP project have no dependencies, and you can easily refactor them without disrupting other infrastructure.

Use the figure to trace how dependency-free IAM policies move into separate configuration without disrupting live infrastructure. section 10.2.1

How Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform covers it

How deep it goes
Defines the pattern and details a staged extraction workflow, stopping short of prescribing one universal module structure.
Examples
Uses GCP IAM policies, service accounts, networks, subnets, and a container orchestrator as extraction examples.
What it assumes
Assumes familiarity with infrastructure resources, configuration repositories, state, deployment plans, and provider APIs.
What you can do after
Apply it via Terraform and provider APIs to separate resources, import existing state, inject dependencies, and verify no unintended changes.
How it connects
Connects infrastructure as code with modularization, dependency injection, state management, and configuration management.

Also explained in

Compare how 8 books explain monolithic architecture →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform. The section links point to the parts of the book it draws on.