Terraform is an open-source infrastructure as code software tool that provides a consistent CLI workflow to manage hundreds of cloud services. Terraform codifies cloud APIs into declarative configuration files.
In this tutorial, we are going to learn how to install Terraform on Fedora 36.
Infrastructure as code (IAC) tools allow you to manage your infrastructure with a configuration file rather than through a graphical interface. IAC allows you to build, change and manage your infrastructure in a safe, consistent, and repeatable way by defining configurations that you can version, reuse and share.
Where do we use Terraform?
Terraform is used in many use cases such as:
- Infrastructure as code. We use Terraform to automate and provision our infrastructure such as servers, databases, firewalls, etc. This helps to accelerate cloud adoption because manual provisioning is always slow and cumbersome.
- Manage network infrastructure. Terraform is used to automate key networking tasks such as updating load balancer member pools.
- For multi-cloud deployments. Terraform helps in deploying serverless functions such as AWS Lambda.
Advantages of Using Terraform
- Terraform can manage infrastructure on multiple cloud platforms.
- The human-readable form helps you write infrastructure code quickly.
- Terraforms state helps you to track resource changes throughout your deployments.
- You can commit your configurations to version control to safely collaborate on infrastructure.
To deploy infrastructure with Terraform you need to understand the following aspects:
- Scope: You need to identify the infrastructure for your project in advance.
- Author: Write the configuration manifest for your infrastructure.
- Initialize: Install all the plugins needed by Terraform to manage your infrastructure.
- Plan: Preview the changes Terraform will make to match your configurations.
- Apply: Make the planned changes to suit your configs
What is good about Terraform is that it keeps track of your infrastructure in a state file. Terraform uses the state file to determine the changes to make in your infrastructure in order to match your configurations.
Install Terraform on Fedora 36
1. Update system repositories.
Before we begin the installation of Terraform, we need to update system repositories in order to make them up to date.
sudo dnf update -y
2. Install dnf-config manager
Dnf-config manager is the means of managing rpm repositories available to dnf. It is used for managing installed but not enabled by default repositories. Add dnf-config with the following command.
sudo dnf install dnf-plugins-core -y
After installation of dnf-config manager is done, we now need to use it to add official Hashicorp Linux repository to our Fedora 36.
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
After you have added to Fedora 36 repository, you can now proceed to install Terraform.
Install Terraform on Fedora 36
To install Terraform on Fedora 36, use the following command.
sudo dnf install terraform -y
The sample output will look like this.
#output ============================================================================= Package Architecture Version ============================================================================= Installing: terraform x86_64 1.2.3-1 hashicorp Transaction Summary ============================================================================= Install 1 Package Total download size: 13 M Installed size: 60 M Downloading Packages: terraform-1.2.3-1.x86_64.rpm 42 MB/s | 13 MB 00:00 --------------------------------------------------------------------------------------------------------------------------------------------- Total 41 MB/s | 13 MB 00:00 Hashicorp Stable - x86_64 48 kB/s | 3.1 kB 00:00 Importing GPG key 0xA3219F7B: Userid : "HashiCorp Security (HashiCorp Package Signing) <[email protected]>" Fingerprint: E8A0 32E0 94D8 EB4E A189 D270 DA41 8C88 A321 9F7B From : https://rpm.releases.hashicorp.com/gpg Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : terraform-1.2.3-1.x86_64 1/1 Verifying : terraform-1.2.3-1.x86_64 1/1 Installed: terraform-1.2.3-1.x86_64 Complete!
In order to verify the installation use
terraform -help command
$ terraform -help Usage: terraform [global options] <subcommand> [args] The available commands for execution are listed below. The primary workflow commands are given first, followed by less common or more advanced commands. Main commands: init Prepare your working directory for other commands validate Check whether the configuration is valid plan Show changes required by the current configuration apply Create or update infrastructure destroy Destroy previously-created infrastructure
Check the version of installed Terraform with
terraform -v command.
$ terraform -v Terraform v1.2.3
We have successfully installed Terraform on Fedora 36. You can proceed to experiment with it now.