How To Install Terraform On AlmaLinux 8, CentOS 8 and Rocky Linux 8

Terraform is a tool for building and maintaining a virtual server infrastructure; it supports multiple cloud providers in one project. Terraform achieves state management through a configured graph of states and modules which can be created, extended, and managed by users.

There are plenty of tutorials online that teach you how to use the tool, but it’s not always easy to grasp the concepts behind it all! What makes Terraform so flexible and powerful is that you have the ability to program your infrastructure in any language or even create your own language based on Python (which some people call "Terraforming".)

Terraform uses a file called The syntax looks like a cross between bash and JSON. A provider is used to connect Terraform to a cloud provider like AWS or Azure. This file defines where to get the data, that is, the provider and its configurations. The file is just a gateway to start working on your infrastructure.

Terraform uses a state file called terraform.tfstate to store what it knows about the infrastructure, whether it’s running or stopped, and all the values of your resources. A module is a code snippet that contains configuration details to perform common tasks such as creating an AWS instance and attaching an Elastic IP address. Terraform modules contain resource configurations that use blocks called "resources" that define how instances should be created and tracked.

Terraform can manage existing resources as well as create new resources. Terraform is not a configuration management tool, but it does have the ability to modify an existing resource by reapplying the same changes over and over.

Have you ever wanted to install a new Linux system? If so, this guide is for you. You are always looking for more ways to automate your work. Alternatively, you are simply curious and want to get started in automation. With Terraform, you can create a complete infrastructure with just one command! This means it’s important that you know how to install and use the Terraform client software.

In this guide, you will learn how to install Terraform on Red Hat Enterprise Linux (RHEL) compatible OS like AlmaLinux 8, CentOS 8, and Rocky Linux 8.. You will also learn how to create a simple AWS EC2 instance and eventually get Terraform up and running.

Installing Terraform on Linux Red Hat Enterprise Linux (RHEL) is an enterprise-class operating system. RHEL has a fairly large user base and is widely used by companies around the world to run their business. RHEL is also used by hobbyists, students and developers to learn Linux, as well as home users who wish to have their very own server at home for web hosting or even streaming media to their devices.


In order to install Terraform on RHEL, you will need to have the following:

  • An RHEL 8 or later compatible OS. This demo uses Centos 8 as the base operating system.
  • A non-root user with sudo privileges set up on the system.

Updating Your System

One of the most important tasks you can do as a computer user is to update your system. This often takes up saving space on your hard drive and installing more applications; however, it will also make your computer much more secure. Updating your system is a required step if you want to install Terraform.

1. You can start updating your system by typing the following command into your terminal window. This will take a while to run, depending on your server's performance.

sudo yum check-update && sudo yum update -y

Sample output: 

updating your system

2. Now, run the following command to install the yum-utils package on your system. yum-utils has been written as a modular package, which will allow adding new functions without modifying the yum-utils code. yum-utils is not a replacement for any currently available RPM function but does provide additional functions that aren’t part of vanilla RPM. You will use this yum-utils package to add the hashicorp repository for terraform later.

sudo yum install yum-utils -y

Sample output: 

install the yum-utils package

Installing Terraform on CentOS 8

Now that your system has been updated, you are ready to install Terraform.

The Centos 8 does not include the terraform package in its repository. This means that we need to use the yum-utils package to add the terraform repository to your system, while terraform is installed via the yum package manager.

1. Run the following command to add the hashicorp repository.

sudo yum-config-manager --add-repo

Sample output: 

add the hashicorp repository

2. Run the following command to verify if the hashicorp repository has been added successfully.

sudo dnf repolist

You will get the following output.

verify if the hashicorp repository has been added successfully.

3. Finally, run the following command to install Terraform on your system using the yum package manager.

sudo yum install terraform -y

Installing Terraform would take a while because it has to download all the required packages from the repository. After you type the above command, simply sit back and wait until the installation is done.

4. When it's finished, you can run Terraform by typing terraform without any arguments in your terminal window.


 install Terraform

5. Run the following command to verify the terraform version installed on your system.

checking the terraform version


In this tutorial, we learned how to install and configure Terraform on RHEL compatible OS like AlmaLinux 8, CentOS 8 and Rocky Linux 8. At the end of this tutorial, you will be able to use Terraform for your own projects. Leave a comment if you have any comments or questions.

Share this page:

1 Comment(s)