Terraform Installation on Ubuntu 22.04

Terraform Installation on Ubuntu 22.04

Terraform is an open-source infrastructure as code (IaC) tool developed by HashiCorp. It allows you to define and manage your infrastructure using a declarative configuration language, known as HashiCorp Configuration Language (HCL), or JSON.

Step 1: Update your system's package list

sudo apt-get update

Step 2: Install Required Dependencies

One such dependency is unzip, which is used to extract the Terraform package after downloading it. To install unzip, use the following command:

sudo apt install unzip

Step 3: Download Terraform

Next, we need to download the Terraform binary from the official HashiCorp website. At the time of writing, the latest version is 1.9.4. You can download it using the wget command:

wget https://releases.hashicorp.com/terraform/1.9.4/terraform_1.9.4_linux_amd64.zip

Step 4: Unzip the Downloaded File

Once the download is complete, you'll need to unzip the downloaded file to extract the Terraform binary. Run the following command:

unzip terraform_1.9.4_linux_amd64.zip

After unzipping, you can verify the contents of the directory using the ls -lrt command:

ls -lrt

Step 5: Move the Terraform Binary to a Directory in Your PATH

To make Terraform accessible from anywhere in your terminal, move the Terraform binary to a directory that is included in your system's PATH. A common choice is /usr/local/bin:

mv terraform /usr/local/bin

Step 6: Verify the Installation

Finally, you should verify that Terraform has been installed correctly by checking its version. Run the following command:

terraform --version

Conclusion

You've now successfully installed Terraform on your Ubuntu system! You can now start using Terraform to define, provision, and manage your infrastructure with ease. Happy coding!