mdawar.dev

A blog about programming, Web development, Open Source, Linux and DevOps.

Install Terraform Manually on Linux/macOS

Installing Terraform is very easy, it’s available as a single binary named terraform.

1. Download the zip archive

Go to the Terraform Downloads page and download the appropriate package for your system.

bash
$# Example downloading the 64-bit Linux zip archive
$wget https://releases.hashicorp.com/terraform/0.12.26/terraform_0.12.26_linux_amd64.zip

2. Unzip the package

bash
$# Unzip the downloaded archive
$unzip terraform_0.12.26_linux_amd64.zip
Archive:  terraform_0.12.26_linux_amd64.zip
  inflating: terraform

If you don’t have unzip installed, then you can install it for example on Debian based systems:

bash
$sudo apt-get install unzip

3. Move the binary to a location available in your PATH

View the list of locations in your PATH:

bash
$# The locations are separated by colons (:)
$echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Move the terraform binary to one of the listed locations:

bash
$sudo mv terraform /usr/local/bin/terraform

4. Verify the installation

bash
$# You should be able to run terraform from any location
$terraform version
Terraform v0.12.26

5. Enable tab completion (Optional)

You can enable tab completion if you’re using bash or zsh.

bash
$terraform -install-autocomplete

Then you can use the Tab key to autocomplete Terraform commands.