Discover how to install Terraform on Rocky Linux 10 in minutes! Learn step-by-step setup, avoid common pitfalls, and start automating your infrastructure today—don’t get left behind in the DevOps revolution! #centlinux #devops #terraform
Table of Contents
Introduction
What is Terraform?
Terraform is an open-source infrastructure as code (IaC) tool developed by HashiCorp. It allows developers and system administrators to define and provision data center infrastructure using a high-level configuration language known as HCL (HashiCorp Configuration Language). Instead of manually configuring infrastructure, Terraform automates the process through simple, readable scripts. Think of it like writing blueprints for your cloud environment—once you write it, you can deploy it again and again with minimal effort.
Terraform supports all major cloud platforms including AWS, Google Cloud, Azure, and more. It enables declarative configuration, meaning you tell Terraform what you want, and it figures out how to get there. Whether you’re spinning up EC2 instances on AWS, configuring a VPC, or setting up Kubernetes clusters, Terraform gives you the power to version, manage, and automate it all from your command line.
Overview of Rocky Linux 10
Rocky Linux 10 is a robust, enterprise-grade operating system that is a direct replacement for CentOS, particularly after Red Hat announced CentOS Stream would no longer be a downstream stable release. Developed by the community and led by original CentOS co-founder Gregory Kurtzer, Rocky Linux is designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux (RHEL).
With the rising popularity of Rocky Linux in enterprise environments, many DevOps professionals are adopting it as the base OS for deploying infrastructure tools like Terraform. Rocky Linux 10 continues to offer the security, stability, and long-term support needed for critical workloads, making it an excellent choice for running infrastructure automation tools in production environments.

Why Use Terraform on Rocky Linux 10?
Benefits of Infrastructure as Code (IaC)
Let’s face it: configuring infrastructure manually is tedious, error-prone, and hard to scale. That’s where Terraform shines. By using code to manage infrastructure, you gain several significant advantages:
- Reproducibility: Write once, deploy anywhere. You can recreate environments consistently across dev, test, and prod environments.
- Version Control: Terraform configuration files can be stored in Git repositories, letting teams track changes over time and collaborate effectively.
- Automation: Automate the creation, updating, and deletion of infrastructure using simple CLI commands.
- Modularity: Break infrastructure into reusable components, improving maintainability and scalability.
Infrastructure as code is the backbone of modern DevOps, and Terraform is one of the most powerful tools in this domain.
Compatibility and Stability of Rocky Linux for DevOps Tools
Rocky Linux’s design philosophy ensures long-term compatibility with RHEL, making it a stable and secure platform for enterprise applications. For DevOps teams, this stability is critical. Whether you’re deploying Terraform, Ansible, Jenkins, or Docker, you can rely on Rocky Linux to offer:
- Predictable release cycles
- Security updates and patch management
- Extensive package compatibility via EPEL and DNF
Installing Terraform on Rocky Linux ensures you’re building your infrastructure automation on a rock-solid foundation—pun intended. Plus, the community-driven nature of Rocky Linux means frequent updates and excellent support channels.
HashiCorp Certified: Terraform Associate 2025 by Zeal Vora
All in One course for learning Terraform and gaining the official Terraform Associate Certification (003).

Pre-requisites for Installing Terraform on Rocky Linux 10
System Requirements
Before diving into the installation, make sure your system meets the following requirements:
- Rocky Linux 10 (64-bit) installed
- At least 1 GB of RAM (more if you’re running multiple services)
- Minimum 500 MB of free disk space
- Sudo privileges for the user performing the installation
- Internet access to download packages from external repositories
These requirements are quite basic, as Terraform itself is lightweight and doesn’t require massive system resources to operate effectively.
User Permissions and Environment Preparation
Terraform doesn’t need root access to run, but you will need superuser (sudo) privileges to install it using the system package manager. Here are a few preliminary steps to get your environment ready:
Create a user (if necessary):
sudo adduser terraformuser
sudo passwd terraformuser
Add the user to the sudoers file:
sudo usermod -aG wheel terraformuser
Update your system packages:
sudo dnf update -y
Install essential tools:
sudo dnf install -y wget curl unzip gnupg2
This prep ensures that your system is secure, up-to-date, and ready for Terraform installation without any hiccups.
VAVALASH Lash Tweezers For Eyelash Extensions Diamond Grip Tweezers For Making Volume And Classic Fans Professional Lash Extension Tweezers 1 PCS Lashes Tweezers (Pink,90 Degrees Thin Tweezer)
$14.90 (as of August 5, 2025 14:26 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Step-by-Step Guide to Install Terraform on Rocky Linux 10
Step 1 – Update System Packages
Keeping your system up to date is the first and most crucial step. Outdated packages can lead to incompatibility issues and security vulnerabilities.
Run the following command to update all installed packages:
sudo dnf update -y
Once the system is updated, it’s a good idea to reboot the machine if a kernel or system-level update was applied:
sudo reboot
This ensures that all changes take effect properly before proceeding to install Terraform.
Step 2 – Add HashiCorp Repository
HashiCorp provides its own official repository for Linux distributions, including Rocky Linux. To add the repo:
Create a new repo file:
sudo tee /etc/yum.repos.d/hashicorp.repo <<EOF
[hashicorp]
name=HashiCorp Stable - $basearch baseurl=https://rpm.releases.hashicorp.com/RHEL/8/\$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://rpm.releases.hashicorp.com/gpg
EOF
Once added, verify the repo was added:
sudo dnf repolist
You should see “hashicorp” listed in the output. If not, double-check the syntax or network connectivity.
Step 3 – Install Terraform Using DNF
Now that the repo is added, you can install Terraform directly using DNF:
sudo dnf install terraform -y
This will install the latest stable version of Terraform available in HashiCorp’s repository.
Step 4 – Verify Terraform Installation
After installation, verify that Terraform was installed correctly:
terraform version
You should see output like:
Terraform v1.8.4
on linux_amd64
If you see a version number and no error, congrats—you’ve successfully installed Terraform on Rocky Linux 10!
Alternative Installation Methods
Manual Installation Using Binary Files
Sometimes, you might prefer to install Terraform manually, especially if you need a specific version or want to avoid using external repositories. Here’s how you can do it using the official Terraform binary from HashiCorp:
Download the binary:
wget https://releases.hashicorp.com/terraform/1.8.4/terraform_1.8.4_linux_amd64.zip
Replace the version number as needed. Always refer to Terraform Downloads for the latest versions.
Unzip the file:
unzip terraform_1.8.4_linux_amd64.zip
Move the binary to your system’s PATH:
sudo mv terraform /usr/local/bin/
Verify the installation:
terraform version
This method gives you better control over versioning, especially if you’re managing multiple environments or testing out pre-release versions.
Using Terraform with Docker on Rocky Linux
For those who prefer containerized solutions, Terraform can be run inside a Docker container. This approach avoids installing any software directly on the host OS.
Install Docker:
sudo dnf install -y docker
sudo systemctl start docker
sudo systemctl enable docker
Pull the official Terraform Docker image:
docker pull hashicorp/terraform:latest
Run Terraform via Docker:
docker run --rm -v $(pwd):/workspace -w /workspace hashicorp/terraform plan
This command mounts your current working directory into the container and runs Terraform from within, which is ideal for clean builds and sandboxed environments.
Late 2020 Apple MacBook Air with Apple M1 Chip (13.3 inch, 8GB RAM, 128GB SSD) Space Gray (Renewed)
$375.00 (as of August 4, 2025 22:48 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Post-Installation Configuration
Setting Up Environment Variables
After installing Terraform, you might want to configure some environment variables for a smoother experience. Some commonly used variables include:
TF_LOG
: Sets the logging level (TRACE
,DEBUG
,INFO
,WARN
,ERROR
)TF_VAR_name
: Custom variables for your infrastructure configuration
Example usage:
export TF_LOG=INFO
export TF_VAR_region=us-east-1
You can add these to your .bashrc
or .zshrc
file for persistent use:
echo 'export TF_LOG=INFO' >> ~/.bashrc
echo 'export TF_VAR_region=us-east-1' >> ~/.bashrc
source ~/.bashrc
Configuring Terraform Backend
Terraform stores the state of your infrastructure by default in a local file called terraform.tfstate
. For collaboration and better state management, it’s recommended to use a remote backend like AWS S3, Azure Blob, or Terraform Cloud.
Here’s an example of configuring a remote S3 backend:
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "env/dev/terraform.tfstate"
region = "us-east-1"
}
}
To initialize the backend, run:
terraform init
Backends allow for locking, team collaboration, and better reliability. Configuring it correctly from the beginning prevents future headaches.
Testing Terraform Setup
Creating Your First Terraform Configuration File
Now let’s get hands-on. You’ll start by creating a basic Terraform configuration file to deploy a simple resource. Let’s say you’re deploying a local file resource (a safe starting point without cloud credentials).
Create a new directory:
mkdir terraform-test && cd terraform-test
Create a main.tf
file:
resource "local_file" "example" {
content = "Hello, Terraform!"
filename = "${path.module}/hello.txt"
}
Initialize Terraform:
terraform init
See what it plans to do:
terraform plan
Apply the changes:
terraform apply -auto-approve
Check the created file:
cat hello.txt
This quick test ensures that your Terraform setup works and helps you understand the typical workflow of init
, plan
, and apply
.
Running terraform init, plan, and apply
Let’s break these commands down a bit:
terraform init
– Initializes the working directory and downloads necessary providers.terraform plan
– Shows what changes will be made to the infrastructure.terraform apply
– Applies the changes described in the plan.
When using these commands, especially in real cloud environments, always review your plan
output carefully to avoid unintentional changes or deletions.
Common Installation Issues and Fixes
HashiCorp Repository Not Found
One of the most frequent problems occurs when the repository URL is incorrectly added or blocked by a firewall.
Fixes:
- Double-check the repository syntax
- Ensure HTTPS and DNS are not blocked
- Use
curl
to test:curl https://rpm.releases.hashicorp.com/gpg
Terraform Command Not Recognized
If you get a “command not found” error, it means your binary isn’t in the system’s PATH.
Fixes:
Verify binary location:
which terraform
Re-add to PATH:
sudo mv terraform /usr/local/bin/
You can also add to the PATH manually in .bashrc
or .profile
if needed.
Best Practices After Installation
Version Management
Once Terraform is installed, it’s important to manage versions effectively, especially if you’re working in environments where infrastructure depends on specific Terraform versions. Using different versions for different projects can prevent compatibility issues with modules or providers.
Recommended Tools:
tfswitch: A command-line utility that lets you switch between different versions of Terraform quickly.
curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash
tfswitch
tfenv: Another version manager that’s popular among developers.
git clone https://github.com/tfutils/tfenv.git ~/.tfenv
echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc tfenv install 1.8.4 tfenv use 1.8.4
By maintaining multiple versions, you can ensure that legacy projects don’t break while experimenting with new features in the latest release.
Enabling Auto-Completion and Syntax Highlighting
To make working with Terraform more efficient, enable shell auto-completion and syntax highlighting.
Enable auto-completion:
Add this to your .bashrc
or .zshrc
:
terraform -install-autocomplete
Then reload your shell:
source ~/.bashrc
Enable syntax highlighting in VS Code:
Install the Terraform extension by HashiCorp or “Terraform” by Mikael Olenfalk. These extensions improve code readability and reduce syntax errors.
Adding these enhancements can save time and reduce mistakes, especially when working with large and complex .tf
files.
Sperry Men’s Authentic Original 2-Eye Boat Shoe
$79.03 (as of August 3, 2025 14:16 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Updating and Uninstalling Terraform
Updating Terraform on Rocky Linux
To update Terraform, first check which version is currently installed:
terraform version
Then, if you’re using the HashiCorp repo:
sudo dnf update terraform -y
If you’re managing Terraform manually or via tfenv
, just use:
tfenv install latest
tfenv use latest
Always test updates in a staging environment before applying them in production. Some Terraform versions introduce changes that might affect state files or provider compatibility.
Clean Uninstallation Steps
If you ever need to remove Terraform from your system:
Remove the binary (if installed manually):
sudo rm /usr/local/bin/terraform
Remove the repository (if installed via DNF):
sudo dnf remove terraform -y
sudo rm /etc/yum.repos.d/hashicorp.repo
Clean up leftover directories:
rm -rf ~/.terraform.d
This ensures your system is clean and ready for a fresh install if needed later.
Read Also: Top 100 Linux Interview Questions for DevOps
Using Terraform with Other DevOps Tools on Rocky Linux
Integrating with Ansible
Terraform and Ansible are powerful together. Terraform excels at provisioning, while Ansible is ideal for configuration management.
Typical workflow:
- Use Terraform to provision infrastructure.
- Use Ansible to configure it after it’s created.
Example:
- Terraform creates an EC2 instance.
- Ansible SSHs into the instance and installs Apache, sets up users, etc.
You can pass data between Terraform and Ansible by outputting values (like IP addresses) and passing them into your Ansible playbooks.
terraform output -json > inventory.json
ansible-playbook -i inventory.json playbook.yml
Using Terraform in CI/CD Pipelines
Integrating Terraform into CI/CD (Continuous Integration/Continuous Deployment) helps automate your entire infrastructure lifecycle. Popular tools like GitLab CI, Jenkins, GitHub Actions, and CircleCI support Terraform workflows.
Best Practices:
- Store state in a remote backend like Terraform Cloud or AWS S3 with locking.
- Use separate workspaces for different environments (dev, staging, prod).
- Use
terraform plan
as a pre-deployment step. - Use approval gates before running
terraform apply
.
Example GitHub Actions snippet:
jobs:
terraform:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.8.4
- name: Terraform Init
run: terraform init
- name: Terraform Plan
run: terraform plan
This type of integration ensures your infrastructure deployments are consistent, traceable, and repeatable.
Conclusion
Installing Terraform on Rocky Linux 10 is a strategic choice for developers and DevOps professionals who prioritize stability, performance, and scalability. The synergy between Terraform’s robust infrastructure automation and Rocky Linux’s enterprise-grade environment provides a powerful platform for deploying, managing, and scaling infrastructure across any environment.
From adding repositories and installing packages to testing your first configuration and integrating Terraform into a full DevOps workflow, this guide walked you through everything you need to get started. Whether you’re automating AWS deployments, managing Kubernetes clusters, or simply setting up VM infrastructure, Terraform on Rocky Linux 10 sets you up for success.
The key is not just installing it—but using it effectively. Configure your environment properly, integrate with version control, manage remote state wisely, and continuously improve your infrastructure-as-code strategy.
Now that you have Terraform installed and running on Rocky Linux, it’s time to automate your infrastructure like a pro.
From setting up scalable AWS solutions to managing complex Linux environments, I’ve got you covered. Visit my Fiverr profile to get started.
Frequently Asked Questions (FAQs)
1. Can I use Terraform with older versions of Rocky Linux?
Yes, but it’s recommended to use Rocky Linux 9 or 10 for full compatibility with HashiCorp’s latest releases. Older versions may lack updated libraries required by Terraform.
2. Is Terraform safe to install on production servers?
Yes, but it’s best to run Terraform from a separate CI/CD pipeline or automation server rather than directly on production machines.
3. What’s the best way to manage multiple Terraform versions?
Use tools like tfenv
or tfswitch
to switch between different versions of Terraform based on your project requirements.
4. How do I uninstall Terraform completely?
Remove the binary, delete any related directories, and clean up the HashiCorp repository from your system as outlined in the uninstallation section.
5. Does Terraform require root access to install?
Root (sudo) access is needed to install Terraform system-wide using DNF. However, you can install and run Terraform manually in user space without root access.
Leave a Reply
Please log in to post a comment.