One of the core philosophies of the DevOps is to treat everything as code. So it does the same with Infrastructure and treats Infrastructure as Code (or IaC). Treating Infrastructure as Code allows one to deploy infrastructure in a predictable and consistent manner, document all changes, mark each change or a group of change as separate version. So all cloud providers have supported this philosophy in some manner. For example, with Microsoft Azure, you can use Azure ARM templates, for AWS you can use Cloud Formation. However, these days, multi cloud deployment scenarios are becoming common. So instead of learning what each cloud provider supports, one can also learn Terraform.
What is Terraform?
Terraform by HashiCorp is an open sourced tool to manage infrastructure as code.
It codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned. It supports multiple providers that allows it to communication with different platforms such as Azure, AWS, Docker, etc. It also allows you to develop your very own provider for your custom platform or application. It also lets operators easily use the same configurations in multiple places to reduce mistakes and save time.
What can Terraform Do?
In it’s simplest form, Terraform uses a single configuration file (.tf) that describes the infrastructure you want to deploy. The files is based on the HashiCorp’s Configuration Language (HCL).
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.
The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc.
Download and Install Terraform
Before you can use Terraform, you need to get access to the CLI. You can download the CLI for the different platforms from Terraform’s website. It’s a single executable that you can run anywhere you need it.
On Windows, you just need to download and run it. Its a download and run executable.
We’ll learn how to download it on the Ubuntu OS. You can modify it as per your distribution of Linux.
First, hover your mouse over the 64-bit Linux version shown, right click and then select copy link address:

We can then open a terminal and run curl command:
curl -O https://releases.hashicorp.com/terraform/0.11.7/terraform_0.11.7_linux_amd64.zip
The above link might change depend upon the releases of the terraform.
Last we need to use unzip the files presented in the downloaded zip file. For that we can use unzip. We would also unzip it to a location like /usr/local/bin or /usr/bin so that it will be auto involved in the list of location search by environment variable PATH.
sudo unzip terraform_0.11.7_linux_amd64.zip -d /usr/local/bin

Verify if Terraform is Installed
We can simply run terraform –version to see if its working for us:
This makes our workstation ready to use terraform. In upcoming posts, we’ll see how to make use of Terraform.