How it works · 25 of 38 Core

What is infrastructure as code (IaC)?

A blueprint you can rebuild from

Infrastructure as code: Infrastructure as code describes servers, networks, databases and firewall rules in a file that a tool builds from, so every copy comes out identical, every change is reviewed like code, and a lost setup can be rebuilt from the file; a change made by hand in the console is drift, and the next run of the tool undoes it.

Loading the animation…

Say it like this Infrastructure as code describes servers, networks and databases in a file that a tool builds from, so every copy is identical, every change is reviewed like code, and a lost environment can be rebuilt from the file; a fix made by hand in the console is drift, and the next apply undoes it.

Under the hood — for builders
Real case: Knight Capital's eighth server (2012)
In a hand deployment, "one of Knight's technicians did not copy the new code to one of the eight SMARS computer servers" (SEC):
No second check
SEC: Knight "did not have a second technician review this deployment".
Infrastructure as code
Cloud resources described in text files that a tool reads and builds the same way every time.
What a plan shows
Terraform's plan reads what exists, then "proposes a set of change actions" to match the file:
Drift
A change made outside the file, by hand: the next plan shows it as a change to undo.
Tools
Terraform / OpenTofu, AWS CloudFormation and CDK, Pulumi, Azure Bicep.
Watch out
The state file is sensitive: share and lock it. Review the plan, not just the code.
Sources
SEC, Release No. 34-70694 and press release 2013-222 (16 Oct 2013) · HashiCorp, Terraform CLI docs, "terraform plan" (read November 2026).

What happens in the infrastructure as code animation, step by step?

  1. Building by hand means clicking through the cloud console from a checklist: pick a machine, a network, a port. Do it eight times and you get eight servers that are almost the same.
  2. Almost is the problem. In 2012 Knight Capital updated eight trading servers by hand and missed one. It ran old code, and Knight lost more than $460 million in 45 minutes (SEC).
  3. Infrastructure as code writes the servers, network, database and firewall into a file. A tool such as Terraform compares the file with what exists and builds exactly the difference, the same way every time.
  4. Your turn: at 2 a.m. a teammate opens port 8443 by hand to fix an outage. Now the cloud no longer matches the file: that is drift. Leave the fix in the console, or write it into the code?
  5. Then the worst day: the Mumbai setup is gone. Point the same file at an empty account in Hyderabad and the whole floor prints again, line by line, identical. A checklist in someone's head can't do that.
  6. So the file is now the truth, and it changes every week, along with the app's own code. Who checks each change before it reaches customers? Next: CI/CD.

What everyday example explains infrastructure as code?

An architect's blueprint. Builders who follow it put up the same house every time; a wall a builder moves on site without changing the drawing gets "corrected" by the next crew that works from it; and if the house burns down, the drawing is how you build it again on another plot.

Why should a team care about infrastructure as code?

When you set up a new environment, decide whether it is built from code or by hand: code for anything you would need to rebuild, copy for testing, or audit; then decide who may change production by hand at all, and how drift is caught.