Skip main navigation

What is Infrastructure as Code?

When learning about Infrastructure as Code in DevOps, it's important to gain an understanding of how infrastructure fits in. This step gives you an overview of infrastructure in the traditional development project timeline and introduces you to Infrastructure as Code (IaC).

When learning about Infrastructure as Code in DevOps, it’s important to gain an understanding of how infrastructure fits in.

This step gives you an overview of infrastructure in the traditional development project timeline and introduces you to Infrastructure as Code (IaC).

Infrastructure in the Traditional Development Project Timeline

GRAPHIC OF PROJECT TIMELINE

Software development projects burn a lot of money and resources waiting for infrastructure to arrive. In the typical software development project timeline, the process of requesting for the provisioning of development, test, and production infrastructure can take anywhere from days to weeks, and sometimes even months.

Once the infrastructure has arrived, you’re still unable to test the software you’ve been creating and as a result, you’re unable to show the software to the customer for feedback.

Think About It: If you’ve ever received a middle-of-the-night emergency support call due to a crashed server, you’ll know the pain of searching through multiple spreadsheets (or even your memory!) to access the manual steps of setting up a new machine from scratch. There’s also the age-old difficulty in keeping the development and production environments consistent.

What is Infrastructure as Code?

A common analogy for using Infrastructure as Code (IaC) is the distinction between owning pets and cattle. When you own pets, you give them names and you treat them individually and if something bad happens to them, you care a lot. If you have a herd of cattle, you might still name them but you treat them as a herd.
In infrastructure terms, if you don’t treat environments as code, there might be severe implications if a machine crashes and you need to replace it (pets). When you use IaC and a machine goes down, you can just spin up another machine with no issues (cattle).
An easy way to remove the possibility of human error when initialising machines and treat environments like code so that they are stood up from a single consistent definition, is to use IaC.
Infrastructure as Code (IaC) is a practice that enables the automation and validation of the creation and teardown of infrastructure (such as networks and virtual machines) to help deliver secure, stable application hosting platforms.

Configuration Management

Infrastructure as Code falls into the category of configuration management and relates to defining or scripting for environments. Configuration management in DevOps is less formal than traditional configuration management.
What this means is that encapsulation of configuration in code is favoured over formal documentation, and that lighter-weight, executable configurations that allow having configuration and environments as code are valuable.

Defining Infrastructure as Code

Infrastructure as Code is specifically defined as follows: Defining your environments to include networks, servers, and other compute resources as a text file (script or definition) that is checked into version control and used as the base source for creating or updating those environments. For instance, adding a new server is done by editing a text file and running the release pipeline, not by remoting into the environment and spinning up one manually.
When designing scripts or definitions for IaC, it’s important to make sure that the code and tools are set up to be idempotent, or able to run multiple times without error and with consistency.
IaC can also be set up with developers’ help because many tools offer code that can be written in familiar programming languages, even ones as simple as JavaScript Object Notification (JSON) definitions.
Some examples of tools for working with IaC are:
  • Vagrant
  • Ansible
  • Puppet
  • Chef
  • Docker
  • Windows PowerShell DSC
  • Cloud-provided tools such as Azure Resource Management templates.

Join the discussion

With an understanding of Infrastructure as Code (IaC), consider the Knight Capital fiasco. In your opinion, what is the cost of failed configuration?
This article is from the free online

Microsoft Future Ready: DevOps Development, Implementation and Azure Automation

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education