liveBook · Manning

Infrastructure as code

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

An infrastructure as code tool is software that provisions, configures, updates, or otherwise manages infrastructure from code or declarative configuration.

Infrastructure as code automates infrastructure changes through code or declarative configuration to improve scalability, reliability, resiliency, and security. It treats infrastructure management as a development life cycle: write configuration, commit it to version control, apply it automatically, and test the result. section 1.0 section 1.2.2

A configuration qualifies as IaC when it can reliably reproduce infrastructure, restore a specific version, and communicate the blast radius of a change. A tool enables the workflow, but does not replace these practices. section 1.2.3

Assess IaC against four principles:

  • Reproducibility recreates expected infrastructure across environments. section 1.3
  • Idempotency makes repeated enforcement safe and predictable. section 1.3.5
  • Composability combines infrastructure components into new configurations while limiting blast radius. section 1.3.5
  • Evolvability allows resources to change without unnecessarily affecting dependent systems. section 1.3.5

Use an implementation workflow that:

  • Expresses resource operations as create, read, update, and delete (CRUD), then orders and automates them. section 2.1
  • Prefers immutable replacement where practical to reduce configuration drift and preserve a source of truth. section 2.4
  • Runs formatting, security, configuration, and infrastructure tests before production delivery. section 6.0 section 7.1
  • Passes secrets as variables and keeps them out of plaintext configuration and version control. section 2.4

Automating repeated server updates

Updating packages manually across ten servers can take about ten hours and repeat configuration drift. After an initial investment of roughly forty hours in IaC, the same update can take less than five minutes across all servers, while automated tests improve predictability and recovery. section 1.4.2

Figure 1.4 A development life cycle for infrastructure includes writing the code as documentation, committing it to version control, applying it to infrastructure in an automated way, and testing it.

Use the life-cycle diagram to connect configuration, version control, automated application, and infrastructure testing. section 1.2.2

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

How deep it goes
Explains principles, CRUD operations, immutability, testing, and delivery workflows without requiring one specific tool or platform.
Examples
Demonstrates server package updates, development-to-production reproduction, network testing, and Python-generated Terraform configuration.
What it assumes
Assumes infrastructure context but recommends introductory Python or Terraform knowledge only for running the concrete examples.
What you can do after
Apply it via Python and Terraform to reproduce, test, update, and remove infrastructure with less drift and failure risk.
How it connects
Connects infrastructure management with version control, continuous delivery, testing, configuration drift, security, and change management.

Also explained in

Compare how 14 books explain infrastructure as code →

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.