Terraform Tutorial: How to Install Terraform ?

Sarath Pillai's picture
How to Install Terraform on Mac and Linux

Cloud infrastructure is being leveraged by almost everyone these days. There are many configuration management tools to manage configuration state of the servers in the form of code. Tools like Puppet, Chef and Ansible are well suited for configuration management. Managing things with code is much more reliable compared to manual effort put by system administrators and operations engineers, it also brings in all the good things that software development methodologies offer(like versioning the configuration state, reverting to a previous state, and collaboration). 

Cloud Infrastructure can also be dealt in the form of code. Hence there are a number of tools that are generally called "Provisioning tools". We are going to see the method to install one such provisioning tool called Terraform on Linux & Mac.

If you are completely new to terraform, the below introduction can be helpful in getting started.


Read: What is Terraform ?


Terraform is used to provision infrastructure on different public clouds. Like Networks, Load Balancers, Security Groups(Firewall), Instances, Create DNS entries, etc. Tools like Puppet & Chef works on a client and server model. There is generally a central Puppet server and then puppet agents on all nodes(similarly there is a central chef server and then nodes with agent installed). Consider terraform as a configuration management for your infrastructure, with a lot of intelligence to maintain a particular state of your infra. Unlike chef and puppet, Terraform does not work in a client and server model.

Terraform is a client only tool, which directly interacts with the cloud provider of your interest and provisions infrastructure components.


Terraform is a tool from Hashicorp. It is written in Go Language.


So Do I Need Go Language to be Installed for Running Terraform?


Well not actually. You do not need "Go" language on your system if you just want to use terraform. Because it is provided as a binary that you can directly execute on the server as any other Linux command.

However, if you are interested in compiling it from the source code, you will then need Go language on your system.


How to install Terraform on Linux?


 Step 1: The very first step is to confirm we have the packages wget & unzip installed. You can do that using the below command.

 For Red Hat / CentOS, Run the below:

#yum install wget unzip


For Ubuntu Distribution, Run the below:

#apt-get install unzip wget


Step 2: The second step is to download terraform binary directly on the server. For this to work, first visit the terraform download page using the link: https://www.terraform.io/downloads.html, and grab the download link as shown below.  Simply right click on the 64-bit Linux option and select the "Copy Link Address".



Step 3: In the linux terminal (of the server where you want to install terraform), enter the command wget followed by a space and then paste the copied link there, and press enter. This will download terraform binary in zip format directly to the server.


root@ip-10-12-2-140:~# wget https://releases.hashicorp.com/terraform/0.11.1/terraform_0.11.1_linux_amd64.zip?_ga=2.244423109.1597180439.1514829700-1217072508.1514829700
--2018-01-01 23:32:33--  https://releases.hashicorp.com/terraform/0.11.1/terraform_0.11.1_linux_amd64.zip?_ga=2.244423109.1597180439.1514829700-1217072508.1514829700
Resolving releases.hashicorp.com (releases.hashicorp.com)..., 2a04:4e42:8::439
Connecting to releases.hashicorp.com (releases.hashicorp.com)||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14709002 (14M) [application/zip]
Saving to: ‘terraform_0.11.1_linux_amd64.zip?_ga=2.244423109.1597180439.1514829700-1217072508.1514829700’

terraform_0.11.1_linux_amd64.zip?_g 100%[==================================================================>]  14.03M  29.1MB/s    in 0.5s    

2018-01-01 23:32:33 (29.1 MB/s) - ‘terraform_0.11.1_linux_amd64.zip?_ga=2.244423109.1597180439.1514829700-1217072508.1514829700’ saved [14709002/14709002]



Step 4: Extract the zip file as shown below.


root@ip-10-12-2-140:~# unzip terra*
Archive:  terraform_0.11.1_linux_amd64.zip?_ga=2.244423109.1597180439.1514829700-1217072508.1514829700
  inflating: terraform               



Step 5: Move terraform binary to /usr/local/bin/


root@ip-10-12-2-140:~# mv terraform /usr/local/bin/


Step 6: Confirm you have terraform installed by executing the terraform command as shown below (which will give you the version details of terraform we just installed).


root@ip-10-12-2-140:~# terraform version
Terraform v0.11.1



Step 7: Clean the unwanted zip archive


root@ip-10-12-2-140:~# rm -f terra*


How to install Terraform on MAC OS X?


The procedure to install terraform on MAC is exactly same, with slight differences. If you have homebrew tool installed on your mac, then installing terraform is just one command away. See below.


brew install terraform


If you do not have brew & admin permission on your MAC, then I would recommend the below method to install terraform.


Step 1:  Make a directory for downloading terraform inside the local user home. Execute the below command on the mac terminal.


cd && mkdir apps



Step 2:  Grab the terraform binary location for MAC as we did earlier for Linux. See below.


Step 3: Paste the link that we copied in step 2, as an argument to the curl command as below (do not forget the -L and -o argument along with the name of the output file, in our case we are naming the downloaded file as terraform.zip).


curl -L -o terraform.zip https://releases.hashicorp.com/terraform/0.11.1/terraform_0.11.1_darwin_amd64.zip?_ga=2.46182887.1597180439.1514829700-1217072508.1514829700
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15.0M  100 15.0M    0     0   560k      0  0:00:27  0:00:27 --:--:--  518k



Step 4: Unzip downloaded binary as shown below.


unzip terraform.zip



Step 5: Run pwd command and copy the output.


$ pwd



Step 6: Run the below command.

Do not forget to replace /Users/sarath/apps in the command below to the output you got in step 5.

echo 'export PATH="/Users/sarath/apps:$PATH"' >> ~/.bash_profile



Step 7: Close the current terminal (where we did all our work), and open a new terminal and run the below command to confirm terraform is installed correctly.


$ terraform -v
Terraform v0.11.1



Rate this article: 
Average: 3.9 (56 votes)


Can you post more details about "Terraform" aport form installation.

Sarath Pillai's picture

Hi Ankit,
Yes for sure. Am already in the middle of drafting 4 more in this series. I will post back here once i publish it.

Wow!!! what a great post on Terraform.
Its simple and Awesome tutorial,Thank you slashroot!
This is good start for installation and understanding Terraform.
Could you please share details about "How To Use Terraform with AWS or other cloud".

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.