Low Orbit Flux Logo 2 F

Terraform - Install

Pre-compiled Binary

Download the version for your system from here: https://developer.hashicorp.com/terraform/downloads


unzip terraform_1.5.1_linux_amd64.zip

Run it from current location:


Compile from Source

This needs golang to be installed and setup first. See our Install Golang page.

Clone the Terraform repo:

git clone https://github.com/hashicorp/terraform.git
cd terraform

Build it:

go install

It will be placed here:


Place it on your Path:

Check your path, and place it into one of the listed directories:

echo $PATH

Alternatively, copy to a directory of your choice (ex. home dir ) and add that directory to your path:

mv terraform ~
echo "export PATH=$PATH:~" >> ~/.bashrc
source ~/.bashrc


terraform -v

Homebrew on Mac OS

Install the HashiCorp repo ( tap ):

brew tap hashicorp/tap

Install terraform:

brew install hashicorp/tap/terraform


terraform -v

Upgrade Homebrew and Terraform:

brew update
brew upgrade hashicorp/tap/terraform

Chocolatey on Windows

choco install terraform


terraform -v

Linux Packages


Update repo and make sure these are installed first:

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

Install HashiCorp key:

wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg


gpg --no-default-keyring \
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \

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

Update repo info:

sudo apt update

Actually install terraform:

sudo apt-get install terraform


Install yum-config-manager:

sudo yum install -y yum-utils

Install HashiCorp repo:

sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

Install Terraform:

sudo yum -y install terraform


Install dnf config-manager

sudo dnf install -y dnf-plugins-core

Install HashiCorp repo:

sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo

Install Terraform:

sudo dnf -y install terraform

Amazon Linux

Install yum-config-manager:

sudo yum install -y yum-utils

Install HashiCorp repo:

sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo

Install Terraform:

sudo yum -y install terraform

Enable tab completion

touch ~/.bashrc   # for bash
touch ~/.zshrc     # for zsh
terraform -install-autocomplete

Terraform First Test / Demo

Create a directory for the configuration.

mkdir test1
cd test1

Define resources and other components here:

terraform { required_providers { docker = { source = "kreuzwerker/docker" version = "~> 3.0.1" } } } provider "docker" {} resource "docker_image" "nginx" { name = "nginx" keep_locally = false } resource "docker_container" "nginx" { image = docker_image.nginx.image_id name = "tutorial" ports { internal = 80 external = 8000 } }

Change your profider if you’re running Windows:

provider "docker" {
 host    = "npipe:////.//pipe//docker_engine"

Initialize, plan, and apply ( more on these in the next section ):

terraform init
terraform plan
terraform apply

You should be able to see a docker container running:

docker ps

You should be able to reach default NGINX web page here:


Destroy your infrastructure with this:

terraform destroy

Help commands:

terraform -help
terraform -help plan