Cloud & DevOps7h estimated

Infrastructure as Code

Difficulty
Importance

The problem

Manually clicking through a cloud provider's console to create servers, networks, and databases is slow, error-prone, and impossible to reliably reproduce — infrastructure as code describes infrastructure declaratively in files, versioned and reviewed like application code, and applied automatically.

Why now

Package management already showed that a dependency graph can be resolved automatically rather than installed by hand in the right order; infrastructure as code applies that same declarative, dependency-aware approach to entire systems — servers, networks, and their relationships — using graph theory's topological ordering to decide what to create first.

Mental model

Infrastructure as code describes the desired end state of your infrastructure — 'a server, a database, a network connecting them' — as a dependency graph, and a tool computes a valid creation order (a topological sort, precisely) automatically, the same problem package managers and build systems already solve, just for cloud resources instead of software packages.

Requires

Used in

Projects

  • Write infrastructure-as-code (Terraform or similar) to provision a simple resource (a storage bucket, a virtual machine) and apply it, then modify and reapply to observe the tool compute only the necessary changes
  • Diagram the dependency graph a real infrastructure-as-code file implies (e.g. a network before a server before a load balancer) and confirm it matches the tool's actual creation order

Examples

  • Defining a database and a server that references its connection string, the IaC tool automatically creates the database first, inferring the dependency from the reference
  • Reapplying the same infrastructure code twice produces no changes the second time — the declarative model computes only the diff needed to reach the desired state

Resources

Mastery checklist