Install terraform on Ubuntu 20.04, CentOS 8, MacOS, Windows 10, Fedora 33, Red hat 8 and Solaris 11
In this guide, we will focus on Installation of Terraform on a various operating system such as Ubuntu 20.04, CentOS 8, Fedora 33, Red Hat 8, and Solaris.
- Install Terraform on Ubuntu 20.04, CentOS 8, Fedora 33, Red Hat 8 or Solaris
- Install Terraform on Windows 10
- Install Terraform on MacOS
Later we are also going to see How to Upgrade Terraform using tfenv?
- Upgrade Terraform using tfenv
- Upgrade Terraform to Specific version using tfenv
- Uninstall the Terraform
1. Installing Terraform on Ubuntu 20.04, CentOS 8, Fedora 33, Red Hat 8, or Solaris
The instructions and command for installing Terraform on
Ubuntu 20.04 OR
CentOS 8 OR
Fedora 33|32|31 is almost same. You only need to pay attention to which version of the host OS you are choosing. Is it 32 bit or 64 Bit?
One more software package you need to preinstall .i.e.
wget because you will be needing this package for downloading
the terraform binary.
In case if you do not have
wget then use the following command to install it -
- Ubuntu 20.04 | 18.10 | 18.04 :
1sudo apt-get install wget unzip
- CentOS 8 | 7 :
1sudo yum install wget unzip
- **Fedora 33 | 32 | 31 ** :
1bash sudo dnf install wget
Download the terraform.zip file
1. Goto Terrafrom.io
2. Click on Download CLI and for Ubuntu
3. On the download page you will find an option Linux, so based on your operating system architecture choose a suitable option (32-bit | 64-bit | Arm | Arm64). I choose the 64 bit
4. Right-click on 64-Bit option then click on Copy Link Location (We need to copy the download link)
5. Open Terminal and use the
wget command followed by the link which you copied in the previous step.
- After successful download you will see a
ZIPfile inside your directory
Unzip and move the file to ‘/usr/local/bin’
1. Unzip the terraform ZIP file
2. After the UNZIP you should see a file named
3. Move the file
1sudo mv terraform /usr/local/bin/
Verify the Terraform installation on Ubuntu
You can confirm the installation by running the following command
It should return you with the version which you have installed. In my case, the version was -
2. Installing Terraform on Windows 10
Download the terraform.zip file
2. Scroll down the page and look for the Windows option. After that you need to select the version 32 Bit | 64 Bit. (In my case I had 64 Bit Windows 10, so I choose 64 Bit option for download)
3. Once you click on either 32 Bit or 64 Bit, it will download a ZIP file for you.
Move and Extract the Terraform ZIP file
1. let’s move the ZIP file to some good location. In my case, I moved the file to
C:\Terraform (You can move the
ZIP file to any location of your choice but always remember the path onto which you are moving the file)
2. Extract the Terraform ZIP file (After the extraction it should have one file
Add the Terraform directory PATH to Windows 10 environment variable
1. Copy the path of the folder where you placed
terraform.exe (In my case the path was
Start Menu and type in the
Environment Variables in the search box and then click on
3. Once you open the environment variables window you need to click on
Environment Variables (You can find it
at the bottom of the window)
Goto -> System Variables then look for the system variable named
5. Click on
Edit and it should open another window. Click on
new and past the path of your terraform directory
Verify the Terraform installation on Windows 10
You can verify the installation by opening the
command prompt and then typing the following command -
If you have successfully installed the terraform then it should return you with the version number.
3. Installing Terraform on MacOS
Install the Terraform on MacOS using brew
This is one of my favorite ways to install any package on my macOS, but here are the steps for installing Terraform using HomeBrew
1. Use the following
Homebrew command it will install the Terraform for you.
1brew install terraform
1==> Downloading https://homebrew.bintray.com/bottles/terraform-0.14.3.catalina.bot 2==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/1172ae8f9a7ac2bed83ca13 3######################################################################## 100.0% 4==> Pouring terraform-0.14.3.catalina.bottle.tar.gz 5🍺 /usr/local/Cellar/terraform/0.14.3: 6 files, 63.9MB
Install Terraform manually on macOS
2. Extract the downloaded ZIP file
3. Move the ZIP file using the following command
1sudo mv $HOME/Downloads/terraform /usr/local/bin/
Verify the Terraform installation on macOS
You can verify the Installation of Terraform on macOS by running the following command
It should return you with the version which you have installed onto your macOS
4. Upgrade Terraform using tfenv
tfenv on Ubuntu 20.04 | CentOS 8 | Fedora 33 | Red hat 8 | Solaris 11
The installation of
tfenv is pretty straight forward but you should at least know how to do
git clone or you
should be familiar with
1. Clone the
1git clone https://github.com/tfutils/tfenv.git ~/.tfenv
2. Add ~/.tfenv/bin to your $PATH
1echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bash_profile
3. Create symlink for
1mkdir -p ~/.local/bin/
1ln -s ~/.tfenv/bin/* ~/.local/bin
4.2 Verify the
You can use the following command to verify the installation of
It should return you with
1tfenv 2.2.0 2Usage: tfenv <command> [<options>] 3 4Commands: 5 install Install a specific version of Terraform 6 use Switch a version to use 7 uninstall Uninstall a specific version of Terraform 8 list List all installed versions 9 list-remote List all installable versions 10 version-name Print current version 11 init Update environment to use tfenv correctly.
4.3 List available version using $ tfenv list-remote
Before upgrading Terraform version, you should check which versions of Terraform are available.
Run the following command to check the available version
You will see the following output based on the latest available version -
10.15.0-beta1 20.15.0-alpha20210210 30.15.0-alpha20210127 40.15.0-alpha20210107 50.14.7 60.14.6 70.14.5 80.14.4 90.14.3 100.14.2 110.14.1 120.14.0
4.4 Install the latest version of Terraform
There is the default latest command provided by
tfenv which will install the latest version of Terraform onto your system
1tfenv install latest
5. Upgrade to a specific version of Terraform
If you really want to upgrade to a specific version of Terraform then always keep the correct version of Terraform handy with you. (At the time of writing this article the latest stable version of Terraform is
1tfenv install 0.14.7
There is one more feature provided by the
tfenv. If you want to upgrade to the latest version of some specific
release for example you want the latest version from 0.14 release then you can do it by running -
1tfenv install latest:^0.14
5.1 Change terraform version (If you have already installed multiple versions of Terraform)
Let’s say you have installed multiple version(0.14.7, 0.14.6, 0.14.5) of terraform and now you want to switch between the versions then use the following command to achieve that
1tfenv use 0.14.6
The above command will switch to terraform to version
But if you use only
terraform use then it will switch the latest version of Terraform.
1 tfenv use
The above command will switch to version
0.14.7 because at the time of writing this article
0.14.7 is latest
the version provided by terraform
6. Uninstall the Terraform
The uninstallation command of the Terraform is very simple -
1tfenv uninstall 0.14.7
1Uninstall Terraform v0.14.7 2Terraform v0.14.7 is successfully uninstalled
Read More -
- Install terraform on Ubuntu 20.04, CentOS 8, MacOS, Windows 10, Fedora 33, Red hat 8 and Solaris 11
- How to setup Virtual machine on Google Cloud Platform using terraform
- Create EC2 Instance on AWS using terraform
- How to use Terraform Input Variables
- What is variable.tf and terraform.tfvars?
- How to use Terraform locals?
- How to use Terraform output values?
- Understanding terraform count, for_each and for loop?
- Cloud-nuke : How to nuke AWS resources and save additional AWS infrastructure cost?
- How to use Terraform Dynamic blocks?
- How to use Terraform resource meta arguments?
- How to use Terraform Data sources?