Skip to main content
πŸŽ“ Claude Code Masterclass Learn AI-assisted development on Udemy β€” plus the companion book on Leanpub & Amazon. Start Learning
How to Install Terraform on RHEL 9
DevOps

How to Install Terraform on RHEL 9

Step-by-step guide to install Terraform on RHEL 9. Covers prerequisites, installation, version verification, and first project setup.

LB
Luca Berton
Β· 1 min read

Prerequisites

Before installing Terraform on RHEL 9, ensure you have:

  • Administrative/root access
  • Internet connectivity
  • A terminal or command prompt

Installation Steps

Step 1: Add the HashiCorp Repository

HashiCorp provides official packages for most platforms:

# Verify your system architecture
uname -m

Step 2: Install Terraform

Follow the official installation method for RHEL 9:

# Download the latest Terraform binary
# Visit: https://developer.hashicorp.com/terraform/downloads

Step 3: Verify Installation

# Check Terraform version
terraform version

# Expected output:
# Terraform v1.x.x
# on linux_amd64 (or your platform)

Post-Installation Setup

Configure Shell Autocompletion

# Install autocomplete
terraform -install-autocomplete

# Restart your shell
exec "$SHELL"

Set Up Your First Project

# Create a project directory
mkdir terraform-demo && cd terraform-demo

# Create main.tf
cat > main.tf << 'EOF'
terraform {
  required_version = ">= 1.5.0"
}

output "hello" {
  value = "Terraform is working on RHEL 9!"
}
EOF

# Initialize and run
terraform init
terraform apply -auto-approve

Managing Multiple Versions

For projects requiring different Terraform versions:

# Install tfenv (Terraform version manager)
git clone https://github.com/tfutils/tfenv.git ~/.tfenv
echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# Install specific version
tfenv install 1.7.5
tfenv use 1.7.5

# List installed versions
tfenv list

Common Issues

Permission Denied

# Fix binary permissions
chmod +x /usr/local/bin/terraform

Command Not Found

# Add to PATH
echo 'export PATH="$PATH:/usr/local/bin"' >> ~/.bashrc
source ~/.bashrc

Version Mismatch

# Check required version in your project
grep required_version *.tf

# Install matching version
tfenv install <version>

Next Steps

Now that Terraform is installed on RHEL 9:

  1. Learn HCL syntax β€” HashiCorp Configuration Language basics
  2. Set up a cloud provider β€” AWS, Azure, or GCP credentials
  3. Create your first infrastructure β€” Start with a simple resource
  4. Use remote state β€” Configure S3 or Terraform Cloud backend
  5. Explore modules β€” Reuse configurations from the Terraform Registry

Master Terraform from zero to production with Luca Berton’s courses β€” practical, hands-on infrastructure as code training.

Free 30-min AI & Cloud consultation

Book Now