How to install Terraform in Ubuntu

Steps to install terraform on Ubuntu / Ubuntu cloud server :

  1. Install unzip

    sudo apt-get install unzip
    
  2. Confirm the latest version number on the terraform website:

    https://www.terraform.io/downloads.html
    
  3. Download latest version of the terraform (substituting newer version number if needed)

    wget https://releases.hashicorp.com/terraform/0.12.18/terraform_0.12.18_linux_amd64.zip
    
  4. Extract the downloaded file archive

    unzip terraform_0.12.18_linux_amd64.zip
    
  5. Move the executable into a directory searched for executables

    sudo mv terraform /usr/local/bin/
    
  6. Run it

    terraform --version 
    

If you’re running Ubuntu plus snap installed, just call:

sudo snap install terraform

What about using Terraform official deb repository, you can than install and update Terraform using apt.

https://www.terraform.io/docs/cli/install/apt.html#repository-configuration

Like this:

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt update
sudo apt install terraform