Nick Jetten | 11 August 2021

Infrastructure as Code

Often at Enjins we set up or extend the cloud infrastructure for our clients. When there is no infrastructure in place, we first need to choose together with our customers the right cloud provider. This means that we work with different cloud providers and resources in the console of the provider.

Setting up and configuring the desired resources requires a lot of steps of selecting, naming and configuring the right resources. You can imagine that this process can be error-prone and when you make a mistake, it is hard to find the error and fix it. Also, this makes you more cautious of every change that you have to make and being worried about to be able to recreate the environment. The solution for the above-described problem is Infrastructure as Code!

In this article the following main questions are answered:

  • What is IaC?

  • Why use IaC?

  • What framework should I choose?

    • Configuration orchestration vs configuration management

    • Mutable vs immutable infrastructure

What is Infrastructure as Code?

Infrastructure as Code (IaC) is the managing and provisioning of infrastructure through code instead of through manual processes. This code describes the infrastructure resources and configurations and are saved in so called configuration files. This gives you a better overview of the resources created and makes it easier to edit those resources, or reuse them.

Why use IaC?

IaC comes with several advantages such as:

Speed: IaC speeds up significantly the process of provisioning infrastructure for development, testing, and production. IaC can automatically adapt to changes in configuration and react to spikes in traffic with resources scaling automatically.

Efficiency: environment drift can be very expensive when the infrastructure was set up manually. When failures happen because the infrastructure in the test environment does not match the production environment, investigation time can rise quickly. IaC also enables engineers to spend more time on developing software and less on managing the resources.

Consistency: By using code instead of manual processes, the infrastructure is easily reproducible. Since it is code, version control can be used to apply CI/CD practices to infrastructure changes. The code can be tracked, tested, reviewed and automatically deployed by other team members and when things go wrong, a rollback can take place. On top of that, writing resources as codes makes them reusable.

Some disadvantages of IaC are that it can be challenging in the beginning to learn these different tools and their code language. Also most of the tools are not free so additional costs are not inevitable. An extra challenge is that developers need to become more responsible for managing infrastructure.

Different frameworks

There are a wide variety of different IaC tools available which each serves it own purpose. They can be divided into two types of tools:

Configuration orchestration and configuration management
Configuration orchestration tools, such as Terraform and AWS CloudFormation are used to automate the deployment of servers and other infrastructure. Configuration management tools like Chef, Puppet, and Ansible are used for configuring infrastructure that is already provisioned. Both types can have some overlap and can be used together to provide an ultimate solution.

 

Source: Infrastructure as Code | How-does-it-work?

Mutable vs immutable infrastructure
When choosing an IaC solution you also have to look at the type of infrastructure the tool is creating. Mutable infrastructure can be modified or updated after it is created. This gives it an advantage of flexibility to customize it after creation, however when there are a lot of changes and this is undocumented, configuration drift can occur. This contradicts in the first place why IaC was used. Therefore, immutable infrastructure, which is infrastructure that cannot be modified after creation is preferred. In this way configuration drift can be eliminated and makes it easier to maintain a more consistent and reliable infrastructure.

Terraform

At Enjins we often choose Terraform as our configuration orchestration tool for provisioning and managing immutable IaC. Terraform became popular over the recent years because of its simple and straightforward syntax that allows easy modularity and works with different cloud providers such as GCP, AWS and Azure. Since Terraform is platform agnostic and the syntax is easy to learn, it became our go to tool for managing infrastructure as code.

In the second part of this article serie, we will dive deeper into Terraform and will give an example of how we set up a common infrastructure that Enjins provides for their clients with Terraform!

Sources:

What is Infrastructure as Code?

What is infrastructure as code and why is it important?

infrastructure-as-code

Want to stay updated?

Please fill in your e-mail and we'll update you when we have new content!