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 -mStep 2: Install Terraform
Follow the official installation method for RHEL 9:
# Download the latest Terraform binary
# Visit: https://developer.hashicorp.com/terraform/downloadsStep 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-approveManaging 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 listCommon Issues
Permission Denied
# Fix binary permissions
chmod +x /usr/local/bin/terraformCommand Not Found
# Add to PATH
echo 'export PATH="$PATH:/usr/local/bin"' >> ~/.bashrc
source ~/.bashrcVersion 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:
- Learn HCL syntax β HashiCorp Configuration Language basics
- Set up a cloud provider β AWS, Azure, or GCP credentials
- Create your first infrastructure β Start with a simple resource
- Use remote state β Configure S3 or Terraform Cloud backend
- Explore modules β Reuse configurations from the Terraform Registry
Related Resources
Master Terraform from zero to production with Luca Bertonβs courses β practical, hands-on infrastructure as code training.
