Tomas Majling, dev-ops på Digitalent

17 September, 2019

What is infrastructure as Code and why is it important?

Infrastructure as Code, IaC, was developed to solve the challenge regarding operation and deployment in several different development environments and is an important part of DevOps. Some even claim that DevOps would not be possible without IaC. We talked to Tomas Majling, backend developer at Digitalent, to hear more about what IaC means and the benefits of embracing the concept.

What is Infrastructure as a code?

”Infrastructure as code” is simply a way to build your IT-infrastructure with code. The most common way is to use it for various cloud platforms such as Amazon Web Services, Google Cloud Platform or Microsoft Azure. With code, you can easily start up virtual servers, databases, networks and other cloud services. How does it differ from traditional infrastructure? The usual way is to set up your infrastructure in a Portal, for example Amazon Web Services (AWS) has its console. It might seem simple that you can easily start a new application with the help of guides in their portal. But over time, it can become more difficult as more and more applications are added and more and more people become involved in the infrastructure. Keeping track of what has been changed and added becomes difficult. If something new is added or changed in the infrastructure that does not work as intended, it will be more difficult to return to a previously functioning state.

What are the benefits of IaC?

By writing your infrastructure in code you can version manage your source code. If something is not working as you want, you can easily go back to an earlier version of the source code. In a portal it may take time to click around to get an understanding of the infrastructure. With IaC, the code is the drawing and documentation of the infrastructure. The infrastructure can quickly be reused in other projects or organizations to create a similar environment. By using configurations and variables in the code you can create an infrastructure for different development environments such as one for QA and one for production. Setting up infrastructure for different environments in a portal requires you to do the same job twice.

How can I get started with IaC?

Start by getting an understanding of your infrastructure platform, such as AWS, through the portal. Then use their own tools to write code, CloudFormation for AWS for example.

Can you recommend any tools to get started with IaC?

To get started, the easiest way is to start by using one of the services' own tools. For example, if you plan to use AWS as a platform, CloudFormation is recommended as it always tests if the code you wrote is correct and if something goes wrong in the creation and start-up of the infrastructure, it automatically backs up what worked last. When you have an understanding for the selected platform I recommend using a generic tool, such as Terraform for creating infrastructure. With a generic tool, you can use multiple infrastructure platforms in the same configuration. So you can create environments for different platforms in the same code, such as AWS and Google Cloud Platform. Here, however, one must be more careful and test the code before deploying it, since it will be creating and changing instances even if something did not work. Most tools will help you review what needs to be added, changed or removed before configuring the environment. For example, you can create a "Change set" in AWS to see what will happen in a graphical interface after you run your configuration. Terraform also has the option to review its configuration before it is run using the "plan" command.

More from Digitalent

Load more