Fedora

How To Install Terraform on Fedora 42

Terraform is an open-source infrastructure as code (IaC) tool by HashiCorp that lets you define, provision, and manage cloud and on-premise resources using declarative configuration files. It supports all major cloud providers – AWS, Azure, GCP, Hetzner, DigitalOcean – along with hundreds of other providers.

This guide covers how to install Terraform on Fedora 42 using the official HashiCorp DNF repository. We also include a basic usage example to get you started with your first Terraform project.

Prerequisites

  • A system running Fedora 42
  • sudo or root access
  • Internet connectivity to reach HashiCorp package repositories

Step 1: Add the HashiCorp Repository

HashiCorp maintains an official DNF repository for Fedora and other RPM-based distributions. Start by installing the dnf-plugins-core package that provides the config-manager command, then add the repository.

sudo dnf install -y dnf-plugins-core
sudo dnf config-manager addrepo --from-repofile=https://rpm.releases.hashicorp.com/fedora/hashicorp.repo

Verify the repository was added:

sudo dnf repolist | grep hashicorp

You should see hashicorp listed in the output, confirming the repository is active.

Step 2: Install Terraform on Fedora 42

With the repository in place, install Terraform directly through DNF. This method handles updates automatically when you run system updates.

sudo dnf install -y terraform

Verify the installation by checking the version:

$ terraform --version
Terraform v1.14.7
on linux_amd64

At the time of writing, the latest stable release is Terraform 1.14.7. You can check the Terraform releases page for newer versions.

Step 3: Enable Tab Completion (Optional)

Terraform supports shell tab completion for subcommands and flags. Enable it for your current shell:

terraform -install-autocomplete

Restart your shell or source your profile for the change to take effect:

source ~/.bashrc

Step 4: Basic Terraform Usage Example

To confirm everything works, create a simple Terraform project that uses the local_file resource to generate a file on your system. This demonstrates the core Terraform workflow – init, plan, and apply – without needing any cloud credentials. If you already manage infrastructure with tools like Packer, Terraform fits naturally into the same provisioning pipeline.

Create a project directory and a configuration file:

mkdir -p ~/terraform-demo && cd ~/terraform-demo

Create the main configuration file:

vi main.tf

Add the following configuration:

terraform {
  required_providers {
    local = {
      source  = "hashicorp/local"
      version = "~> 2.5"
    }
  }
}

resource "local_file" "example" {
  content  = "Hello from Terraform on Fedora 42!\n"
  filename = "${path.module}/hello.txt"
}

Initialize the project to download the required provider plugin:

terraform init

Preview the changes Terraform will make:

terraform plan

The plan output shows that Terraform will create one resource – the local_file.example file. Apply the configuration to create the file:

terraform apply -auto-approve

Verify the file was created:

$ cat hello.txt
Hello from Terraform on Fedora 42!

To tear down the resource and clean up:

terraform destroy -auto-approve

This same workflow applies to real infrastructure. You can deploy VM instances on Hetzner Cloud with Terraform or provision VMs on KVM with Terraform using the same init, plan, apply cycle.

Useful Terraform Commands

CommandDescription
terraform initInitialize a working directory and download providers
terraform planPreview changes before applying
terraform applyApply changes to create or update resources
terraform destroyDestroy all managed resources
terraform fmtFormat configuration files to canonical style
terraform validateCheck configuration syntax and consistency
terraform state listList all resources in the state file
terraform outputDisplay output values from the state

Conclusion

Terraform is now installed on Fedora 42 from the official HashiCorp repository, which keeps it updated through standard DNF operations. The init-plan-apply workflow shown here applies to any provider – from local files to full cloud deployments across AWS, Azure, or GCP. For production use, store your state file remotely (S3, Terraform Cloud, or Consul) and use version-controlled configuration repositories. Terraform also works on other Linux distributions if you manage mixed environments.

Related Articles

Ansible How To Use Ansible Playbook With Vagrant up Automation Deploy VM instance on OpenStack using Terraform Fedora How To Install KVM on Fedora 43/42/41/40 Fedora Fedora 42 vs Ubuntu 25.04: Detailed Comparison Table

Press ESC to close