So you wanna learn Infrastructure As Code huh? Maybe you’ve heard about it and want to understand more about the topic, or maybe you’re evaluating whether it’s right for your business. Whatever your reason for needing to know what Infrastructure As Code is, you’re in the right place.
For Cloud Native software engineers, Infrastructure As Code is an essential skill. You’ll need to understand and implement Infrastructure As Code to achieve any moderately large Cloud architecture in a professional way. So it’s safe to say that learning Infrastructure As Code is a great investment.
By the end of this article you should understand what Infrastructure As Code is, what the benefits are, and how you can get started using Infrastructure As Code today.
In todays article we’ll cover:
- What Is Infrastructure as Code? — We’ll define what Infrastructure As Code actually is.
- Why Learn Infrastructure As Code? — In this section we discuss the personal benefits to learning Infrastructure As Code.
- What Are the Benefits of Infrastructure as Code? — In this section we discuss why you’d want to implement Infrastructure As Code in the first place.
- What Does Declarative Infrastructure As Code Mean? — Infrastructure As Code tools can be said to be declarative or imperative, we discuss what the difference is and why it matters.
- What Are the Main Infrastructure as Code Tools? — We discuss the different Infrastructure As Code tools.
- How Can I Get Started with Infrastructure as Code? — We talk about the best way to get started learning Infrastructure As Code.
Sound good to you? Let’s get to it.
What is Infrastructure As Code?
Let’s start by defining what Infrastructure As Code is. Infrastructure As Code is the practice of keeping all of your infrastructure code within version control. When your code is managed in version control you get benefits such as: you can apply the same code review processes as you would to regular code.
One of the better ways to understand the definition of Infrastructure As Code is to consider the anti-thesis: Manually created infrastructure. Manual infrastructure is infrastructure that has been created by an individual, and rather than documented in code it’s documented in textual format, or worse not at all.
Why Learn Infrastructure As Code?
Before we get more into the benefits and the what of Infrastructure As Code, let’s briefly take a look at some of the benefits, and why you’d want to learn Infrastructure As Code.
There are many reasons to learn Infrastructure As Code for the benefits of a business. But are there any personal benefits to an individual from learning Infrastructure As Code? And of course the answer is yes. So what are some of those reasons? Let’s take a look.
Infrastructure as Code Can Reduce Frustration When Making Infrastructure Changes
Learning Infrastructure As Code can reduce your frustration when implementing cloud infrastructure. When you provision or modify resources manually it can be hard to keep track of what changes have been made which can make experimenting with changes more difficult.
Infrastructure as Code Makes It Easier to Manage Costs
If you’re working in the cloud it can be easy to create and forget about resources. Before you know it, you’re hit with a large bill for resources you didn’t lose. But when all created resources were made through code rolling back those changes is easy.
What Are The Benefits of Infrastructure as Code?
Okay, so now that we know what Infrastructure As Code is. What are the main reasons that we’d want to invest in it?
Infrastructure As Code aids team collaboration
When Infrastructure is written as code, different team members are able to collaborate on the software in the same way they would with regular application code through tools like Github. Code that is added can be easily linked to issue tracking systems to document reasoning.
Infrastructure As Code can then also be executed as part of a build pipeline. When you use Infrastructure As Code in a build pipeline the whole team gets visibility on what has been executed, when, and by whom. When it comes to deployments and debugging issues having traceability is a very useful feature.
Infrastructure As Code ensures we can recover from disasters
By having Infrastructure As Code it means you can usually recover from disasters quicker. If all infrastructure is all created manually, it all has to be manually rebuilt. However, when we have our infrastructure written as code we can typically just re-run our scripts to have the same software provisioned again.
Infrastructure As Code documents our features
As we touched on briefly before, Infrastructure As Code helps to document features. When commits and pull requests are made into version control it becomes easy to retrace our steps and understand why code was written.
Infrastructure As Code helps us to refactor existing infrastructure
Due to the nature of being able to easily re-run Infrastructure when it’s written as code, and not manually means that refactoring existing infrastructure is more easy to achieve. If a change didn’t apply properly, the previous changes can be reverted to and rolled out.
Main Infrastructure As Code tools
Now that we’ve covered what Infrastructure As Code is, and why we’d want it you might be wondering: But what are the main tools that implement Infrastructure As Code, and what are their differences? Let’s quickly introduce the main Infrastructure As Code tools, and explain a little about them.
- Terraform — Terraform is a tool created by Hashicorp. It’s independent of other cloud providers and is mostly used for resource provisioning.
- CloudFormation — CloudFormation is the implementation of Infrastructure As Code in AWS.
- Puppet / Chef — Puppet and Chef are configuration management tools that help you to script your configuration changes.
- Ansible — Ansible is a stand-alone infrastructure as code tool. Engineers use Ansible to run remote commands on servers via SSH.
When it comes to comparing Infrastructure As Code tools, a topic that comes up fairly often is the idea that Infrastructure As Code tools can be declarative, but what does that really mean? Let’s look at that now.
What does Declarative Infrastructure As Code Mean?
Not allInfrastructure As Code is born the same. We have two flavours: Declarative and imperative. Declarative infrastructure as code declares the end state that you want your infrastructure as code to achieve. Then, your infrastructure as code tool will work out what changes are required in order to get there. Whereas imperative Infrastructure As Code is a step by step instruction on how to create infrastructure.
DeclarativeInfrastructure As Code typically comes with the ability to operate on the full life-cycle create, update, delete etc. Whereas imperative typically only works on the ones that have been coded for, so just creating, or updating, or deleting.
For a more in-depth explanation, read the full article on Declarative vs. Imperative Infrastructure As Code
Get started with Infrastructure As Code?
If you’re wanting to start learning cloud tools, the first step that I’d recommend is taking a look at Infrastructure As Code. Why? To get the long answer, read 5 Important Reasons To Learn Terraform Before Cloud Computing. But the short answer is: It has fast feedback loops, it’s easy to rollback and you’re less likely to mess up on cloud costs.
So if you’re looking to get started with Infrastructure as code, the first tool I’d recommend you’d learn is Terraform. First up I’d suggest reading the article: Learn The 6 Fundamentals Of Terraform — In Less Than 20 Minutes. And then I’d suggest setting up an AWS account so that you can experiment. I wrote a free guide that you can get when you sign up to the newsletter which walks you through, step-by-step how to bootstrap your AWS account to get up and running with Infrastructure As Code.
And that concludes our run through of Infrastructure As Code for today. I’m hoping that gave you a better picture of what Infrastructure As Code is, why you’d want to learn it and how you’d get started learning.
If after that introduction you’re itching to read more about Infrastructure As Code, here’s everything I’ve written on the topic so you can dive in to the topics that matter the most to you.
- What Is the Best Way to Learn Terraform?
- Create An AWS S3 Website Using Terraform And Github Actions
- What is Immutable Infrastructure?
- 3 Steps To Migrate Existing Infrastructure To Terraform
- 5 Important Reasons To Learn Terraform Before Cloud Computing.
- Terraform Modules: A Guide To Maintainable Infrastructure As Code
- Declarative vs. Imperative Infrastructure As Code
- Learn The 6 Fundamentals Of Terraform — In Less Than 20 Minutes
- 3 Terraform features to help you refactor your infrastructure effortlessly
- Infrastructure As Code: A Quick And Simple Explanation.