What is Terraform and Why Terraform

While working with any cloud like Azure, we can create resources through UI like Azure portal, Azure CLI,...etc. But this is a manual process, and you must follow the same steps every time you want to create the resource. Through this manual process, there are chances of introducing errors and may not consistently achieve the same expected results.


Instead of creating resources manually, we can create the resources through code, which can be called Infrastructure as Code (IaC). Through IaC, we can automate the infrastructure creation process and make it repeatable and reliable. IaC (Infrastructure as Code) allows us to scale up or down the resource based on application load and usage.


We can do Infrastructure as Code using the Terraform tool. Terraform was developed by Hashicorp company, and it is open-source. Terraform is a good tool for writing the code for Infrastructure in HCL (HashiCorp Configuration Language). HCL is the declarative configuration language where we define our infrastructure. Executing this code with the help of Terraform will create our infrastructure on selected cloud platforms like Azure, AWS, and Google Cloud.


Using Terraform, we can create infrastructure on various cloud vendors like Azure, AWS, and Google through plugin providers. For example, by using azurerm provider on Terraform, we can build infrastructure on Azure. Please find below the high-level diagram for Terraform usage.



HCL is just a scripting language like JSON and YAML. Hashicorp created this language as a human-readable configuration format, which can also translate to machine-readable format YAML or JSON.


Why Terraform?

Terraform allows us to reliably and repeatably create an infrastructure through code with expected results. We can also extend it's functionality through various plugin providers. It supports multiple cloud vendors like AWS, Azure, and Google Cloud. Irrespective of the cloud vendor we use, we can run our infrastructure code on any platform through Terraform. It also allows us to write our own provider and extend Terraform to work with cloud platforms it doesn't support. We can make Terraform code deployment automated through pipelines.