Techโ—โ—โ—โ—โ—Difficulty 4 of 5

How can a whole data center be described in a text file?

If servers are set up from a file, hundreds of machines can be built the same way, and a bad change can be reverted.

โ–ถ Start the story

A whole can be described in a text file because the files tell machines exactly how to set themselves up. This is infrastructure as code: managing and provisioning data center resources through machine-readable definition files, instead of by hand. The same code can create one server or hundreds, the same way each time.

Martin Fowler remembers the old way as the Iron Age. To release a new server application you had to find physical hardware, configure it and deploy onto it, and getting the hardware usually took months. Now, in the Cloud Age, firing up a new server is a matter of seconds and needs only an internet connection and a credit card. Software commands create servers, set them up and tear them down.

Speed is not the main point, though. When people build servers by hand, different readings of imprecise instructions, let alone errors, produce snowflakes: servers with subtly different configurations that cause faults that are hard to debug. The rule of infrastructure as code is that nobody logs in to a server and makes adjustments. Every change goes into the code instead.

Building servers by hand or by code

By hand

  • Each server set up a little differently
  • Faults are hard to debug
  • Few records of what changed

As code

  • Every server follows the same file
  • Changes are recorded and tested
  • Roll back to the last working version

The code is then kept in , so every configuration and every change is recorded for , and it can be tested like any other program. Using configuration code makes changes safer, faults are found and fixed more quickly, and at worst changes can be reverted to the last working configuration. It's the same safety net programmers have for their own code, applied to the machines that run it.

Quiz me

0/3

  1. 1.What problem do 'snowflake' servers cause?
  2. 2.What is the difference between declarative and imperative infrastructure code?
  3. 3.Why keep infrastructure definitions in source control?

Recap

Describe the machines in a file, never tweak them by hand, and treat the file like code.

๐Ÿ’ก A trick to remember it ยท No hand-made snowflakes: if the booklet isn't followed, the castle won't match.

Surprising fact ยท A 2020 report found around 200,000 potential vulnerabilities in infrastructure-as-code templates.

Sources (2)

No source, no claim. Every fact in this lesson (15 claims) cites at least one of these.

  1. [1]Infrastructure as code ยท Wikipedia
  2. [2]Infrastructure As Code ยท martinfowler.com
More lessons in ๐Ÿ’ป Tech (3) See all tech lessons โ†’

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson โ†—