Terraform is a popular platform that automates your deployment tasks. It also enables you to build, modify, and version infrastructure efficiently. Terraform facilitates you to manage infrastructure on various cloud providers.
This guide aims to elaborate on the process of installing Terraform on Ubuntu 22.04.
How to Install Terraform on Ubuntu 22.04?
Follow the guidelines to install the Terraform on the Ubuntu 22.04 operating system.
Step 1: Update System Repository
The command presented below will keep your Ubuntu system up to date, thus enhancing your system performance:
sudo apt update |
---|
To avoid the compatibility issue, first verify that your Ubuntu system has the updated versions of installed packages.
Step 2: Download Terraform GPG Key
Use the wget command to download the GPG key from HashiCorp’s official website and add it to the keyrings directory on your system:
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg |
---|
Once the downloading process has finished, the system will show the progress report on your terminal screen.
Step 3: Add the GPG Repository to the Sources List
After downloading the GPG key, run the given-below command to add the key to your system’s source list:
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list |
---|
The command successfully added the GPG key to the source list of your machine.
Step 4: Refresh the System Repository
To refresh and integrate the new files to your Ubuntu 22.04 machine, use the update command in your terminal:
sudo apt update |
---|
When the update command runs, you will notice new files containing the keyword “hashicorp” in the list. This information indicates that you have added HashiCorp’s GPG key to your Ubuntu machine.
Step 5: Install Terraform via APT
Now, utilize the APT package installer to complete the installation process of Terraform:
sudo apt install terraform -y |
---|
During installation, you can notice the system configuring the Terraform package on your Ubuntu 22.04 machine.
Step 6: Verify Installation of Terraform
The installation of Terraform can be confirmed using the command:
terraform --version |
---|
The –version option will provide information about the Terraform packages like their version number (v1.7.3) and architecture (linux_amd64).
Finally, you have successfully configured the Terraform on your Ubuntu 22.04 system.
How to Uninstall Terraform on Ubuntu 22.04
These guided steps will remove the Terraform from your Ubuntu 22.04 operating system.
Step 1: Completely Remove the Terraform
With this command, you can completely remove the Terraform along with the dependencies:
sudo apt autoremove --purge terraform -y |
---|
Step 2: Confirm Uninstallation of Terraform
Verify whether the purging command has successfully removed Terraform from your Ubuntu machine:
terraform --version |
---|
When you see the above message on your screen, it shows that the Terraform has been removed and is no longer available on your Ubuntu 22.04 system.
Conclusion
You can install Terraform from a trusted source through a few commands. After downloading and adding HashiCorp’s GPG key to the system’s source list, run the command sudo apt install terraform -y to configure the Terraform on your system.
This guide provides a comprehensive process for installing Terraform on the Ubuntu 22.04 machine.
Leave feedback about this