How to install Terraform on Ubuntu

This post explains how to install Terraform on Ubuntu.

Step 1: Update the system


sudo apt-get update


Step 2: Install required packages


sudo apt-get install -y gnupg software-properties-common curl


Step 3: Add the HashiCorp GPG key


curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -


Step 4: Add official HashiCorp Linux repository


sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"


Step 5: Update to add the repository


sudo apt-get update


Step 6: Install the Terraform CLI.


sudo apt-get install terraform


Step 7: Verify installation with below command

terraform -help

You should see output similar to as shown below on successful installation.

    

Usage: terraform [global options]  [args]

The available commands for execution are listed below.
The primary workflow commands are given first, followed by
less common or more advanced commands.