Terraform Overview

Why must we use Terraform?

There are several advantages that Terraform offers, but companies use it for the following three major reasons:

Version control

Problem: Traditionally, our team would have to create dozens of resources manually in the cloud platform based on some specified needs. We soon discovered that this practice was not only a time waste but also brought about errors and unorganized resource creation. When and where they were no longer needed, we had to delete those, often proving to be a headache in terms of wasted team time.
Solution: We used Terraform; an amazing and very popular IaC tool to use the concept of code management to control infrastructures. An infrastructures that is controlled using Terraform with Git version control and a hosting server, for example, GitHub and Bitbucket, makes easy to have version control of infrastructures. This enables

Reusability

Problem: Previously, creating the same cloud resource multiple times would require one to manually repeat the process on the respective cloud platform. This was an extremely time-consuming and redundant task, especially in corporate settings where we often work with the same cloud resource provisioning. For instance, suppose we wanted to create many identical virtual machines in AWS. We would have to do so one by one through doing nothing but typing on the keyboard.
Solution: Terraform also has a feature called Module that allows us to achieve reusability. We can write repeated code inside a module and then use that module whenever we need to apply that code again. You can think of modules like functions in a programming language. Just as you define a function once and call it multiple times in a program, you define a module once and use it multiple times in your Terraform configuration.

State of the Cloud

Problem: One of the biggest issues when working in a team in the cloud is that we are not aware of what has been provisioned in our infrastructure or what has been currently in use. It occurs when someone creates a resource without notice, thereby confusing people and leading to inefficiencies. For example, if a team member decides to deploy a new virtual machine in AWS without bringing it to others' notice, then this can result in
Solution: This can easily be solved by having the team create cloud resources with the help of Terraform. Terraform provides a Statefile that every member of the team can see which resources are running currently in the cloud infrastructure. The State file is simply a JSON file that contains information regarding all the resources created by Terraform.

How does Terraform work?

Each cloud provider, like AWS, GCP, or Microsoft Azure, has its own APIs. The functionality to create, delete, and update resources within the environment of that cloud provider is exposed through these APIs. Therefore, in essence, it will use the APIs of the respective cloud provider to do the necessary operations regarding the management of the infrastructure.
One of the great advantages of Terraform is that it supports working with lots of different cloud services. To make this a reality, Terraform has offered plugins for each of the supported cloud providers, referred to as providers. These provider plugins contain any necessary code and logic to interact with the respective cloud APIs.
When you run Terraform to provision or update your infrastructure, appropriate provider plugins act as agents for you with the involved cloud APIs. In reality, the translation of your high-level configuration set up in Terraform to the low-level API calls that create, delete, or update some of the corresponding resources in the cloud is carried out by these provider plugins.

Related Pages

Feedback

Was this page helpful?