Before starting what Terraform is and how it’s useful in DevOps culture, Let me ask you one simple question. How would you handle the same configuration and deployment for the same settings, environment to hundreds of servers within no time and can make it scalable anytime?
Well, the answer is very simple: you would either write policies and would develop a framework internally to do these infrastructure management tasks. But why reinvent the wheel when tools like Ansible, Chef, Terraform, etc are already there. Now as you understood that you would need a tool which can do these things for you with little instructions.
For example, Let’s say you are working on AWS and want to launch several EC2 instances of a permitted instance type. What you need to do is just define the instance type and number of instances in a configuration file, and let tools like Terraform use these instructions to communicate with the AWS APIs to create those instances. Scaling is easy too in this case. You just need to modify the configuration file, like rebooting the instances or increasing or decreasing the number of instances, attaching security groups to it, and so on.
The above example defines what we call Infrastructure as Code. And Terraform is one of those IaC tools.
So, now asking literally, What is Terraform?
Terraform is a tool provided by Hashicrop for building, changing, and versioning infrastructure safely and efficiently. It can manage not only existing on-prem solutions but also can work for almost all popular cloud service providers like AWS, Azure, GCP. It is one of the most important tools being used by DevOps these days.
Watch the video to know more about what Terraform is by Arman Dadgar (Co-Founder, CTO of Hashicorp)
Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied.
As Terraform officially says, Terraform can manage low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc.
How Terraform works and how it helps DevOps practices?
Well, this article is just an introductory one. So, I will explain with minimal details. Terraform is basically split into two components. One is Terraform Core and the other is Terraform plugins.
It is a compiled binary used as a Terraform CLI and written in GoLang.
Terraform Core serves below main features:
- Infrastructure as Code tool
- Resource state management
- Plan Execution
- Communicating plugins using RPC
- Construction of the resource graph
Terraform plugins are also executable binary written on GoLang which is invoked by Terraform core over RPC. Each plugin serves either a service like AWS or a provisioner like Bash. It has several built-in provisioners, and service providers are discovered dynamically. Terraform Core provides a high-level framework that hides the details of plugin discovery and RPC communication, so developers do not need to know these functionalities in-depth
Terraform plugins main features are:
- To Initialize any mentioned libraries that use to make API calls
- To Authenticate with the Infrastructure Provider like AWS, GCP, Azure, etc.
- It defines Resources that map to specific Services
- And most importantly executing commands or scripts on resources after creation or while destroying those resources.
Who should learn Terraform?
It’s not limited to but it would be surely helpful in their jobs, career growth are mainly for below professionals:
- DevOps/DevSecOps Engineers
- System Professionals who deal with Infra settings, deployments, etc.
- Cloud Engineers who work with the deployment of Cloud Infra
- Developers, who have an interest in Infra automation.
- Cloud Security Professionals
Is there any Certification available for Terraform professionals?
Be it to showcase or filter out through the HR process, Certification is something which requires to show that they know the fundamentals and can work efficiently on Infra as Code tasks/projects. It has only one certification for Terraform professionals i.e. Terraform Associate exam from HashiCorp to verify their basic infrastructure automation skills. The exam is of 1 hour and costs approx $75 valid for 2 years. You can try Sample questions here to understand your Terraform knowledge.
I am pretty sure this article would help you to understand what Terraform is and why it is important for any Infra professionals to learn it. So, go ahead and learn Terraform, clear the Terraform certification. You will surely be recognized by your employers and peer fellows.