Terraform is a software which allows you to manage cloud infrastructure resources from code efficiently. You can use Terraform to build, change, and version infrastructure deployed on proprietary cloud providers or your own infrastructure on premises.

It supports cloud service providers like AWS, Google Cloud Platform, Azure, and many others.

Terraform  is distributed as a binary package for all supported platforms and  architectures. Terraform runs as a single binary named terraform. Any  other files in the package can be safely removed.

In this tutorial we will learn how to:

  • install terraform on CentOS 8
  • install terraform on Ubuntu 18.04

Install Terraform on Centos 7

Next, we will see how we can install Terraform on CentOS 7 distribution.

First up, you will need to upgrade your system and packages to current version:

sudo yum update

Next, we will install wget and unzip packages if they’re not already installed:

sudo yum install wget unzip

Now we are ready to download Terraform zip file for Linux from the official website. At the time of writing  this article, the current version of Terraform was 0.11.13.

wget https://releases.hashicorp.com/terraform/0.12.18/terraform_0.12.18_linux_amd64.zip

Next, we will unpack the archive to /usr/local/bin/

sudo unzip ./terraform_0.12.18_linux_amd64.zip -d /usr/local/bin/

All done. The only thing that is left now, is to check if terraform is successfully installed, with the following command:

terraform -v

Install Terraform on Ubuntu 18.04

To update the system and packages, you can use the built-in software updater, or manually update the system with:

sudo apt-get update

Again, we will install wget and unzip packages if they’re not already installed:

sudo apt-get install wget unzip

Also next, we will run the same commands as we did with CentOS 8:

wget https://releases.hashicorp.com/terraform/0.12.18/terraform_0.12.18_linux_amd64.zip

sudo unzip ./terraform_0.12.18_linux_amd64.zip -d /usr/local/bin/

And finally, to test if our installation was successful:

terraform -v