Chapter 5. Infrastructure As Code
YOU’RE SITTING AT HOME, WATCHING A MOVIE AND EATING POPCORN, with your feet up and the family gathered around you. The phone rings—it’s your on-call system administrator.
“The datacenter has been hit by a tornado—it ripped right through our cage. What do we do?”
Once you get over the obvious answer, you start running down the list:
Pause the movie.
Sign up for an account with a cloud computing provider, to replace the raw computing, network, and storage resources you have lost.
Start uploading/downloading the off-site backups of your customer and application data to the new infrastructure.
Provision enough servers to bring the company back online, assigning an appropriate role to each new server resource (“web server,” “database server,” “monitoring server,” etc.).
Change your DNS to point to your new infrastructure, with a “we got hit by a tornado” page.
Restore the customer and application data.
Remove the “we got hit by a tornado” page.
Finish the movie.
One hour and forty-five minutes later, you’ve gone from business-ending natural disaster to finishing your family movie night. How did you do it? You built the original infrastructure as code: a series of interconnected services, relying on each other to bring each component of the system into the proper running state. All you had to do was apply that code to new resources and restore the application data, and you knew you would get the entire business back up and running from scratch.