Infrastructure as Code, if you have never heard of it, can sound quite intimidating. But I must say that as a DevOps engineer, it might be one of the most fun things I get to work with! It is also at the heart of a healthy cloud environment. So let’s walk through it!
When I was at University, I lived with my housemates in a somewhat questionable apartment. Let’s just say that my housing situation has significantly improved since then – in many ways. During those days, every couple of months, I would leave the big city to visit some friends who lived in a beautiful Dutch village for the weekend. One of my joys was that they had this amazing bath-jacuzzi with cool underwater lighting and jetstreams that can massage your whole body.
In my city apartment, we had a shower that sporadically changed temperature while you dj’d the faucets, a badly isolated window that allowed the wind to swirl past your exposed feet, and a shower curtain that expressed its love by sticking to your body with every turn you made. You can imagine that the occasional bathing experience was supreme.
Now, once you are in the tub and you have the bubbles going, all is well. However, getting the conditions right is always a challenge. You need to make sure that the water is at the exact temperature you need, the jets only start when the water is above the right mark, the tub doesn’t overflow. The whole relaxing experience can be ruined if it takes forever to get the right conditions.
Setting up the Tube
Let’s say that, for our very advanced tubbing experience, the whole setup process can be automatically set up for you. All you have to do is tell the system exactly what you want.
One way to set the right conditions would be clicking through a menu like the one below.
You can go through all the tabs to set the exact thing you need. This works especially well for the one-time bath you are visiting the hotel. It’s clear, and you even enjoy clicking through the menu to see what all the options are.
However let’s say you are a hotel manager, and you have to keep track of the bathing conditions your regular guests use. You want to make sure that every time they arrive, they experience the same, perfect experience.
For this situation, you would make use of a template that stores the requirements the guests have previously used. This way you can fill out a ‘form’ with the needed information. It might look something like this.
Using a template like this has several benefits. Let’s finally take a look at infrastructure as code to elaborate on these.
From the Tub to the Cloud
The needed computers, networking, and storage resources that you would like to make use of in the cloud, are what we call cloud infrastructure. By clicking through a selection menu, or providing the cloud providers with a template, you can ‘place your order’ with them. You place the orders in the same way you would code out the template for the tub, and thus you are ordering your cloud infrastructure – as code.
These orders can be placed using different scripting/programming languages that are unique to the cloud provider, like ARM templates for Microsoft Azure or Terraform templates that can place orders at multiple cloud providers.
Infrastructure as code allows for repeatable cloud environments. Once you have the code written and it works, you can place the same order again and again. This way you ensure that it always looks the exact same way. If you are setting up huge virtual environments in the cloud that require hundreds, if not thousands of resources, it makes sure that every time you place the order it just works!
Cloud infrastructure, by design, is to be used and destroyed. By using infrastructure as code templates, with one click, you can automate their creation. This means that you can have the specific computing environment you need in a couple of minutes – without having to click through hundreds of menus.
By using a template that works, you can prevent human error. If you have to manually install all the needed resources, you are bound to make a small mistake here and there. Using a template removes the ability for a human to make a mistake when placing an order.
This is a big one. Programmers use version control platforms such as GitHub that track and remember all the changes made to any code. This means that you can always ‘go back’ to any template you have used in the past in case something goes wrong. This provides significant peace of mind when you make changes to your infrastructure cloud environment.
The Future with Cloud
As a large part of DevOps is enabling automation, infrastructure as code enables me to create consistent, working environments for clients that want to move to the cloud.
For faster speed to market, keeping cloud environments secure, letting developers test their applications quickly, and making sure everything is repeatable, you need an IT team that can manage infrastructure as code.
Without it, you could never take full advantage of what the cloud truly has to offer.