← Lessons

quiz vs the machine

Gold1400

System Design

Infrastructure as Code

Defining servers and networks in version controlled files for repeatable provisioning.

5 min read · core · beat Gold to climb

Defining infrastructure in files

Infrastructure as Code means describing your servers, networks, and cloud resources in text files instead of clicking through a console. Those files are stored in version control and applied by tooling to create or update real resources.

Declarative vs imperative

  • Declarative you describe the desired end state and the tool figures out the steps. This is the most common style.
  • Imperative you write the exact sequence of commands to run.

Declarative tools track a state of what exists and compute the difference, or plan, needed to reach the target.

Why it helps

  • Repeatable spin up identical environments for dev, staging, and production.
  • Reviewable changes go through code review and leave an audit trail.
  • Versioned you can see history and roll back to a known good config.
  • Less drift the files are the source of truth, reducing manual surprises.

A key practice is reviewing the plan before applying it, so you see exactly what will change.

Key idea

Infrastructure as Code captures resources in version controlled declarative files, making provisioning repeatable, reviewable, and auditable while reducing configuration drift.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a declarative infrastructure tool do?

2. Why review the plan before applying?

3. What is one benefit of storing infrastructure in version control?