liveBook · Manning

Immutable infrastructure

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

Immutable infrastructure is an infrastructure-management approach in which any configuration change is applied by creating a new resource rather than modifying an existing one.

Immutable infrastructure creates a new resource for every configuration change instead of modifying an existing resource. Replacing resources can reduce failure risk and configuration drift by aligning deployed state with infrastructure as code. section 2.2

Apply the approach through replacement and reconciliation:

  • Create a new server with Python 3 and compatible dependencies, then delete the old Python 2 server. section 2.2
  • Generate a new machine image for server updates, passing resource-specific values such as IP registration through startup parameters. section 2.2
  • If an urgent out-of-band change modifies a resource directly, update version control and infrastructure as code to reconcile actual and desired state. section 2.2.1
Figure 2.2 You treat the server mutably by logging in and updating the Python package version. By comparison, you treat the server immutably by replacing the old server with a new one upgraded to Python 3.

Compare in-place Python updates with replacing the server using an upgraded resource. section 2.2

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

How deep it goes
Defines replacement and explains reconciliation, but stops short of detailed deployment orchestration.
Examples
Uses Python 2-to-3 server replacement, machine image builders, and an out-of-band server update.
What it assumes
Assumes infrastructure as code and version control, while defining immutable and mutable infrastructure explicitly.
What you can do after
Apply it via infrastructure as code by replacing resources and reconciling emergency mutable changes in version control.
How it connects
Connects infrastructure as code with mutable infrastructure, configuration drift, version control, and idempotency.

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.