What is Infrastructure as Code?
Infrastructure as Code, told as a story about building a whole park from a single blueprint.
Every time a new park goes up, someone builds it from memory, one at a time.And it comes out a little different, city to city.
Build it by hand, and it differs person to person, with no record of how.City A's park and City B's park end up subtly different.
With just one blueprint, you can build the exact same park anywhere.The blueprint is the source of truth, not any one person.
Read the same blueprint, and even a different builder gets the identical result.And any change leaves a record in the blueprint's history.
Secretly hand-edit it, and the blueprint no longer matches reality (drift).And then there was no point writing the blueprint at all.
Infrastructure as Code = writing the park's blueprint down as a single piece of code, so that whoever builds it, wherever, the result is the identical park.
Writing infrastructure like servers and networks as declarative blueprints (code) and keeping them under version control. A sneaky manual edit causes drift, where reality no longer matches the blueprint, and running the same blueprint again and again should always produce the same result (idempotency). GitOps is the next step — treating that blueprint repository as the one source of truth.
When grown-ups say it
- Infrastructure as Code
- Writing the blueprint down as a single piece of code. With just that blueprint, anyone builds the same park.
- Declarative blueprint
- A blueprint like "ride x1, booth x1". You write the desired result, not the steps to get there.
- Drift
- Reality no longer matching the blueprint. Happens when someone secretly hand-edits things.
- Version control
- A record of when and how the blueprint changed. You can always see later who changed what.
- Reproducibility
- The same blueprint always producing the same park. City A or City B, the result is the same.
- Idempotency
- Running the blueprint again and again gives the same result. Run it twice, and you still don't get two parks.
- GitOps
- A way where construction follows automatically when the blueprint changes. It automatically connects updating the blueprint to building it. → construction that follows the blueprint automatically
- Immutable infrastructure
- Not patching — building new and discarding the old. Removes the chance to hand-edit at all, which prevents drift.