BitBootcampBitBootcamp ← all explainers 🔄 Review ⚙ Settings

DEVOPS-05-001-P · Primer — What Is Infrastructure as Code?

The idea in one sentence

Infrastructure as Code (IaC) means you describe your servers, networks, and databases in text files that live in version control, then let a tool build exactly what you wrote — instead of clicking buttons in a cloud console by hand.

Why it exists

Picture the "old way." You need a web server, so you log into the AWS or Azure console and start clicking: pick a machine size, attach some storage, open a firewall port, wire up a load balancer. It works. Three months later you need an identical server for staging, and you try to remember every click. You miss one firewall rule. Now staging behaves differently from production, and you spend a day hunting the difference.

That hand-driven approach is called click-ops (or manual provisioning). It has three chronic problems:

IaC exists to convert that fragile, human process into a durable artifact. When the desired state of your infrastructure is written down as code, it becomes something you can version, review, test, and replay — the same disciplines software engineers already use for application code.

How it works

The core move is simple: you write a file that declares the end state you want, and a tool figures out how to make reality match it.

  1. You write a configuration file. In a declarative tool, you describe what should exist — "one virtual machine of this size, with this disk, in this network" — not the step-by-step clicks to create it. HashiCorp's Terraform, AWS CloudFormation (JSON/YAML templates), and Azure's tooling all work this way. The tool's job is to compute the steps needed to reach your declared state.

  2. You commit that file to version control (Git). This is what makes infrastructure version-controlled. Every change is a commit with an author, a timestamp, and a message. Every change can go through a pull request so a teammate reviews it before it touches anything real. You can see the full history and revert a bad change.

  3. The tool reconciles desired state with actual state. You run the tool (e.g., terraform apply). It compares what you declared against what currently exists and makes only the changes needed to close the gap. Run it once, you get the environment. Run the same file a second time and nothing happens — the world already matches. This property is called idempotency: applying the same configuration repeatedly converges on the same result instead of stacking up duplicate resources.

Because the file is the source of truth, reproducibility falls out for free. Point the tool at a new account or region, run the same code, and you get a byte-for-byte equivalent environment. Staging and production stop drifting apart because they're built from the same declared blueprint.

The one gotcha

IaC does not magically know about changes you make by hand. If someone opens the console and clicks to add a firewall rule that isn't in the code, you now have drift: the real world and the code disagree. The next time the tool runs, it may "helpfully" delete that out-of-band change to restore the state your file declares — because your file, not the console, is the source of truth.

The rule that keeps you safe: once infrastructure is codified, change it only through the code. No more sneaking into the console for "just one quick tweak." If you must inspect drift, most tools offer a plan/preview step (like terraform plan) that shows you the difference before anything is applied. Treat that preview like a code review diff — read it every time.

See it — click-ops vs codified provisioning

flowchart TB
  subgraph Manual["Click-ops (manual)"]
    H["Human clicks in<br/>cloud console"] --> R1["Environment exists<br/>(steps not recorded)"]
    R1 --> D["Drift + guesswork<br/>on the next rebuild"]
  end
  subgraph Codified["Codified provisioning (IaC)"]
    F["Config file<br/>declares end state"] --> G["Commit to Git<br/>(reviewed in a PR)"]
    G --> T["Tool applies<br/>(idempotent)"]
    T --> R2["Reproducible<br/>environment"]
  end

The one-line takeaway

Infrastructure as Code turns "remember how you clicked it" into "read the file and replay it" — reproducible, reviewable, version-controlled provisioning.

Where you'll meet it

Named concepts: infrastructure as code, reproducibility, version-controlled infrastructure, manual provisioning vs codified provisioning