How to Install Terraform on CentOS

Introduction

Terraform is an open-source Infrastructure as Code tool that helps you manage and create your infrastructure using one interface for multiple providers. The software lets you automate infrastructure provisioning using machine-readable configuration files.

This guide will show you how to install Terraform on CentOS using two different methods.

How to install terraform on CentOS

Prerequisites

  • A user account with sudo privileges.
  • wget and unzip installed.
  • Access to the terminal/command-line tool.

Install Terraform on CentOS

There are two methods to install Terraform on CentOS. The primary method is using the Terraform zip archive that contains the executable you can unpack anywhere on your system.

The other method is using HashiCorp repository for CentOS systems.

Install Terraform on CentOS Using Zip Archive

To install Terraform on a CentOS system using the downloaded zip file, follow the steps below:

1. Browse to the Download Terraform page.

2. Select the Linux tab under the Operating System heading. The latest version is preselected.

3. Scroll down and right click the Download button for your system’s architecture. In our case, it is AMD64. Select Copy Link.

Terraform Linux download page

4. Use the wget tool to download the file:

wget <a href="https://releases.hashicorp.com/terraform/1.3.5/terraform_1.3.5_linux_amd64.zip">https://releases.hashicorp.com/terraform/1.3.5/terraform_1.3.5_linux_amd64.zip</a>
wget Terraform download CentOS terminal output

5. Chose a user directory in &PATH where you will extract the Terraform binary:

echo $PATH
The echo $PATH command to locate directories.

This guide will use /usr/local/bin.

6. Unzip the file to the selected location. Use the full zip archive name including the extension:

sudo unzip terraform_1.3.5_linux_amd64.zip -d /usr/local/bin

Note: The file name is different for different versions and different architectures. Copy the file name after you download it.

CentOS output when unzipping the Terraform archive

The output shows the terraform directory where the extracted file is located. Optionally, you can use the list command to check if the Terraform directory is located in the selected location. In our case:

ls -l /usr/local/bin

7. Run the command to check the Terraform version and verify the installation is successful:

terraform -version
CentOS output for Terraform versiob

The output shows the Terraform version you downloaded.

Install Terraform on CentOS Using Package Repository

The HashiCorp repository contains other non-Terraform packages that will be available for installing after you add the repository.

Follow the steps to install Terraform from the official HashiCorp repository on a CentOS system.

1. Install the yum-utils tools:

sudo yum install -y yum-utils
Install yum-utils on CentOS output.

2. Add the HashiCorp repository:

sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

3. Finally, install Terraform using the yum package manager:

sudo yum -y install terraform
Terraform installed output on CentOS

The output show that Terraform is installed. You can double-check by running the terraform -version command to see the installed Terraform version.

Conclusion

In this guide, we covered how to install Terraform on CentOS using the Terraform binary and the official HashiCorp repository.

Check out our article comparing Terraform vs Puppet for further reading or learn how to install Terraform on Windows, macOS, or other Linux distributions.

Was this article helpful?
YesNo
Goran Jevtic
Goran combines his leadership skills and passion for research, writing, and technology as a Technical Writing Team Lead at phoenixNAP. Working with multiple departments and on various projects, he has developed an extraordinary understanding of cloud and virtualization technology trends and best practices.
Next you should read
VMware vCloud Availability Tenant Setup Guide
August 12, 2019

VMware vCloud Availability 3.0 is a single interface for workload migration, cloud-to-cloud disaster...
Read more
VMware vCloud Director Tutorial & Quick Start Guide
July 2, 2019

A quick start guide to phoenixNAP Virtual Private Datacenter and Data Security Cloud products. Both of these...
Read more
How to Install Veeam Backup and Replication
April 27, 2023

Veeam Backup & Replication is a software solution responsible for protecting your data by performing...
Read more
How to Configure & Setup AWS Direct Connect
September 25, 2018

AWS Direct Connect establishes a direct private connection from your equipment to AWS. Use AWS Direct Connect...
Read more