DEV Community

Cover image for What Is Infrastructure as Code, and Why Terraform?
Pavan Belagatti
Pavan Belagatti

Posted on

What Is Infrastructure as Code, and Why Terraform?

Part of this article is originally posted on Medium
Before going to the core part, let's talk about IaC.

Infrastructure as Code:

Traditionally, the infrastructure setup used to take a long time with a lot of manual processes associated, but with the introduction of tools like Terraform, Chef, Ansible, Puppet, SaltStack, etc, it has become simple to manage, configure and provision the infrastructure setup.

IaC gives wings to the Dev and Ops teams that involves automatically managing and provisioning the technology stack through software.

IaC supports DevOps because you can automate everything. Here, you can treat everything as a software even if they are servers, databases, or networking components, and you can write software for managing all of it, automate it and deliver that continuously.

IaC is sometimes referred to as programmable or software-defined infrastructure.

But Wait,

When we say Infrastructure as Code, we will be haunted with three other words. What are those?

Configuration management, Configuration Orchestration and Provisioning.

So are they all the same? Different? Confusing?
Let me know if I am defining them correctly.

Configuration management tools like Chef, Puppet, Ansible, SaltStack, etc, are designed to install and manage software on existing servers. It could be the installation of packages, starting of services, placing scripts or config files on the instance, etc.

So basically Config Management is part of the provisioning. “Provisioning” often implies it's the first time you do it. Config management usually happens repeatedly.

Configuration orchestration tools like Terraform, CloudFormation, etc, are designed to provision the servers themselves. It refers to arrangement and coordination of automated tasks resulting in a consolidated process or workflow.

Now, we are interested in knowing more about Terraform,

Take a look at this Google trend for the term ‘Terraform.’ The image clearly depicts the popularity of this tool worldwide. Since from 2016, this tool is making good progress, and many have adopted it as one of their essential tools in their DevOps toolchain.

Terraform Vs. CloudFormation trend on Google

Terraform is a tool for developing, changing and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. Terraform is the first multi-cloud immutable infrastructure tool that was introduced to the world by HashiCorp, released three years ago, and written in Go.
DevOps is about culture and practices that aim at uniting development processes. Terraform is a tool and has become more popular because it has a simple syntax that allows easy modularity and works against multi-cloud. One Important reason people consider Terraform is to manage their infrastructure as code.

Infrastructure as code is also a key and foundation for DevOps practices such as version control, code review, continuous integration, and continuous deployment. If you try to search “infrastructure-as-code” on Google, you will come up with a list of tools, and anybody will get confused to see so many options. But Terraform is one tool to consider because of its excellent features and exceptional reasons (that we have listed further in this article) when compared to other similar tools.

Reasons to Consider Terraform for DevOps

As we already know, the goal of DevOps is to perform software delivery more efficiently, and we need some tools to make this delivery quickly and efficiently, this is where the tools like Terraform help companies with infrastructure as code and automation.
Terraform is revolutionizing the DevOps world by transforming the way infrastructure is managed, and making it faster and more efficient to execute DevOps. You might have used technologies like Ansible, Chef, or Puppet to automate and provisioning of software, Terraform starts from the same law, infrastructure as code, but focuses on the automation of the infrastructure itself. Your whole Cloud infrastructure (instances, volumes, networking, IPs) can be easily defined in terraform.

Let us see the reasons to consider Terraform as one of your DevOps tools,

  1. Terraform lets you define infrastructure in config/code and will enable you to rebuild/change and track changes to infrastructure with ease. Terraform provides a high-level description of infrastructure.

  2. Terraform is the only sophisticated tool that is completely platform agnostic as well as supports other services while there are a few alternatives, but they are focused on a single cloud provider.

  3. Terraform enables you to implement all kinds of coding principles like having your code in source control, the ability to write automated tests, etc

  4. Terraform is the right tool for infrastructure management as many other tools have a severe impedance mismatch from trying to wrangle an API designed for configuring management to control an infrastructure environment. Instead, Terraform matches correctly with what you want to do- the API aligns with the way you think about infrastructure.

  5. Terraform has a lively community and is open source; there is a massive community developing around this tool. Many people are already using it, and it’s easier to find people who know how to use it, plugins, extensions, professional support, etc. This also means Terraform is evolving at a much faster rate. They do releases very often.

  6. Terraform’s speed and operations are exceptional. One cool thing about Terraform is, it’s plan command lets you see what changes you’re about to apply before you apply them. Code reuse feature and Terraform tends to make most changes faster than similar tools like CloudFormation.

For the reasons mentioned above, Terraform makes a great tool when it comes to DevOps and hence this tool is getting a lot of attention recently. What is your take on this tool? Let me know if you have any other reasons to use Terraform that I have not mentioned in the list.

Further reading,
Terraform CLI Cheat Sheet

Infrastructure as Code with Terraform

Why we use Terraform and not Chef, Puppet, Ansible, SaltStack, or CloudFormation

Top comments (1)

david_j_eddy profile image
David J Eddy

"...Config Management is part of the provisioning. “Provisioning” often implies it's the first time you do it. Config management usually happens repeatedly...."

Interesting division you have between Config Mngt and Provisioning. Myself Provisioning means 'starting the hardware'. Whereas Config Mngt does, as the name implients, configures the hardware or in the case of a compute resource, configures the software on the hardware. Config Mngt therefor is involved with both 'new' and 'existing' hardware.

"...Configuration orchestration tools like Terraform, CloudFormation..."

In your mind how does Config Orch. differ from Provisioning tools?

"...the goal of DevOps is to perform software delivery more efficiently,..."

Kyle nailed what DevOps should be in his recent article:

Keep up the writing Pavan, I look forward to the next article from you.