Getting started with Terraform

pradeepbhadani profile image Pradeep Bhadani Updated on ・2 min read

Originally published at pbhadani.com

Learn to setup Terraform on your workstation in this step-by-step guide.

Alt Text

Photo by Firdouss Ross on Unsplash

What is Terraform?

Terraform is an open-source tool allows to build, change and version our infrastructure in an easy and efficient way.
It uses declarative language HCL (Hashicorp Configuration Language) to define infrastructure as code.

Terraform concepts

Let's quickly learn about some concepts in Terraform.

  • Providers
    Terraform Providers enables interaction with APIs and handle authentication of different IaaS(e.g. Google Cloud Platform, Amazon Web Service, Azure) or SaaS(e.g. Cloudflare). There are many Terraform supported providers already available and a full list can be seen here.

  • Resource
    Terraform Resource is a very important component. Each resource block describes the infrastructure object(e.g. VM instance, Storage buckets, DNS records, Cloud NAT).

  • Modules
    Terraform modules are the collection of resources defined in a way that can be reused.

  • Data Sources
    Terraform Data Sources help to read infrastructure which is created using (or without using) Terraform.

  • State
    Terraform State stores information about the infrastructure created by Terraform code. It is used by Terraform to detect changes in the resources defined in the code.

Terraform state is stored on local machine by default in the name of terraform.tfstate but can be stored remotely on systems like Google Cloud Storage(GCS), AWS S3.

Let's setup Terraform

Below steps are for Linux based system. For MAC, download the relevant package and the rest of the steps should be the same.

  1. Download the latest terraform package from terraform.io/downloads.

    export TF_VERSION=0.12.16
    wget https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip -O /tmp/terraform.zip
  2. Unzip the terraform binary to a directory which is included in your system PATH.

    sudo unzip /tmp/terraform.zip -d /usr/local/bin/
  3. Reload your shell.

    exec -l $SHELL
  4. Verify installation.

    terraform --help

Below is the terminal recording:

Hope this blog help you get started quickly with Terraform.

Posted on by:

pradeepbhadani profile

Pradeep Bhadani


Working in Big Data, AWS, GCP, DevOps technologies.


markdown guide

If you are on a Mac, chtf makes life a lot more fun when working with terraform: github.com/Yleisradio/homebrew-ter...

it might not matter as much your first day, but as time goes on; being able to quickly switch your terraform version to a supported one for your project is critical to saving time and frustrations.


sometimes it is frustrating to switch terraform version when you have multiple repos with different version.

I have been using github.com/tfutils/tfenv to switch terraform version.

I will give a try to chtf. THanks for the link.