Infrastructure as Code: A DevOps Dive
If you’ve ever had to manage servers that are in a traditional data center, you know how difficult and time consuming it can be. Even if you’re not directly responsible for routing cables and installing hardware, you still have to manage configuration documentation and invest untold hours in software installation, patching, and updates.
On top of all that, when it comes time to upgrade the machines themselves, you have to plan for a large capital expense and you have to provision for your maximum estimated capacity, even if you don’t operate at that level most of the time. It’s a big expenditure in time, resources, and money.
You probably already know that cloud computing platforms, like Amazon Web Services (AWS), simplify a lot of this. For starters, you can convert your capital expense into an operational expense because you’re no longer owning hardware. Next, you can rely on the managed services of AWS to take care of a lot of software updates and patching. For example, the Amazon Relational Database Service (Amazon RDS) automates time-consuming administration tasks, such as hardware provisioning, database setup, patching and backups. You’ll never need to install or patch MySQL again.
But what about everything else? What about the rest of the software you need installed? What about provisioning new servers and all the manual work that entails? What about the steps you need to follow in precise order, the ones you’ve been meticulously keeping in your configuration documentation?
What if that could all be managed so that it was fast, easy and readily repeatable?
At Media Temple, we’ve harnessed the power of infrastructure as code, or “IaC”. IaC is the representation of all the machines and services, software installations, updates, patches, networking and configurations in your environment, taking the form of code. It abstracts away the physical server headaches and replaces them with flexibility, reversibility, and repeatability. IaC has been around for the better part of 10+ years, and it’s found its biggest benefits on the cloud, because unlike in a traditional data center, resources in the cloud are made to be ephemeral disposable.
Let’s take a look at some of the benefits you get with IaC:
Infrastructure as code is super fast. Once you’ve written and tested your IaC, you can deploy an infrastructure of many dozens of servers and have your application up and running on it within a matter of minutes.
Let the computers set up the other computers! You don’t need to install anything on your servers; you just need to kick off the process you’ve articulated in your code and let the machines do the work.
Just as you can roll back to the last stable version of your application’s codebase, with IaC, you can roll back to the last stable version of your server configuration. This allows you to do extensive testing with minimal effort before you move into production and, should you implement an incorrect configuration setting or set a disk capacity too low, you can readily revert.
All the runbooks you were sifting through to provision the servers in your data center? Now that’s all committed in your code, so you don’t have to follow them manually anymore.
Design Patterns and Reuse
IaC allows you to find quality design patterns and to reuse them as best fits your environment and application needs. It reduces the amount of work you need to do to get to the infrastructure you need.
You can try new things without having to worry about getting back to what worked before. Every configuration, every machine can be easily replaced—you don’t need to agonize over the time you spent setting it up because you’ve committed that set up in your code, so setting up a new one takes moments.
All of these reasons on their own are a great justification for building your environment with IaC, and they’re all part of why we use this DevOps process exclusively at Media Temple to support our customers on AWS. It has additional benefits for us—and for you, if you’ve got a large team—like facilitating supportability across a distributed team and having a central source of truth for any given infrastructure under our management.
There are many commercially available tools for building and managing IaC, like Chef, Puppet, and Terraform. It’s very easy to get started with any of them. Although we have experience with all of three, we use our own custom tooling to manage and deploy our infrastructures.
Our managed IaC tooling has a few distinct advantages. It allows us to target very small changes in an infrastructure, rather than re-deploying an entire stack of servers and applications, which helps us quickly get customer requests into production. Our tooling also manages the state in the stacks themselves, rather than in a state file, which can cause disaster if it’s ever corrupted or lost. We’re also able to lock stacks as our support agents work, which prevents collisions and ensures our customer infrastructures are only being modified by a single support agent at any given time, until the final commit.
So the next time you’re hunched over a configuration wiki trying to divine a package dependency or sort out why a machine isn’t coming up, think about giving IaC a try. It’s easy to spin up a Virtual Private Cloud (VPC) and invoke a test deployment. We think you’ll find it paves the way for you to focus on the more important things in your infrastructure. We know we’ve found it’s been invaluable for us and our customers, as well.
To learn more about how Media Temple uses infrastructure as code in the cloud, connect with an AWS-certified expert, today!