This guide will walk you through the steps to install Terraform on Ubuntu / Debian / CentOS / Fedora / Arch Linux system. Terraform is a cloud-agnostic Infrastructure automation tool used to manage cloud and on-premise resources. With it you can build, change, and version infrastructure deployed on popular service providers.

install terraform fedora 29 fedora 28

Before downloading terraform we need to install wget and curl tools

# Debian / Ubuntu systems
sudo apt update
sudo apt install wget curl unzip

# RHEL based systems
sudo yum install curl wget unzip

How to Install Terraform on Linux

We shall consider two methods of performing the installation of Terraform on Linux systems.

Method 1: Install Terraform from upstream repository

Terraform developers maintains APT & YUM repositories for installing the latest releases pf Terraform.

Add repository and install Terraform using the commands below.

### Debian / Ubuntu ###
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform

### CentOS / RHEL ###
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y install terraform

### Fedora ###
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
sudo dnf -y install terraform

### Amazon Linux ###
sudo yum install -y yum-utils shadow-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
sudo yum -y install terraform

Method 2: Install Terraform on Linux from tarball

Terraform is also distributed as a tarball on Github. Check the latest release on Terraform releases page before downloading below.

TER_VER=`curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | grep tag_name | cut -d: -f2 | tr -d \"\,\v | awk '{$1=$1};1'`
wget https://releases.hashicorp.com/terraform/${TER_VER}/terraform_${TER_VER}_linux_amd64.zip

Once the archive is downloaded, extract and move terraform binary file to the /usr/local/bin directory.

$ unzip terraform_${TER_VER}_linux_amd64.zip
Archive:  terraform_xxx_linux_amd64.zip
 inflating: terraform

$ sudo mv terraform /usr/local/bin/

This will make the tool accessible to all user accounts.

$ which terraform
/usr/local/bin/terraform

Check the version of Terraform installed

$ terraform --version
Terraform v1.6.4
on linux_amd64

To update Terraform on Linux, download the latest release and use the same process to extract and move binary file to location in your PATH.

Also check:

LEAVE A REPLY

Please enter your comment!
Please enter your name here