How to Install Terraform on Ubuntu 20.04
This tutorial exists for these OS versions
- Ubuntu 22.04 (Jammy Jellyfish)
- Ubuntu 20.04 (Focal Fossa)
- Ubuntu 18.04 (Bionic Beaver)
On this page
Terraform is an open-source infrastructure automation tool created by HashiCorp. It's written in the Go programming language. You can browse its source code on Github. It allows you to define and describe your infrastructure as code inside configuration files using a declarative language known as HashiCorp Configuration Language (HCL), and to deploy and manage that infrastructure across a variety of public cloud providers. With Terraform you can build, change, and destroy infrastructure on your preferred cloud provider from the command-line. The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc.
The basic workflow when using Terraform is:
1. Write configuration files on your computer in which you declare the elements of your infrastructure that you want to create.
2. Tell Terraform to analyze your configurations and then create the corresponding infrastructure.
This guide will show how to install Terraform software on Ubuntu 20.04 LTS.
Install Terraform
Terraform is very easy to install. Terraform is distributed as a single binary that you can download from the Terraform download page. Select the appropriate package for your operating system and architecture, unzip the archive, and move the binary to a directory included in your PATH variable.
First, create ~/bin
directory:
mkdir ~/bin
NOTE: On Ubuntu, if you create a bin directory in your home directory it will automatically be added to your PATH variable.
Next, download the zip archive. Visit the Terraform download page for the latest version to download.
wget https://releases.hashicorp.com/terraform/0.13.5/terraform_0.13.5_linux_amd64.zip
Unzip the archive. The archive will extract a single binary called terraform
.
unzip terraform_0.13.5_linux_amd64.zip
Move the terraform
binary to a directory included in your system's PATH
in our case that's ~/bin
directory.
mv terraform ~/bin
To check whether Terraform is installed, run:
terraform version
# Terraform v0.13.5
Terraform has four major commands: terraform init, terraform plan, terraform apply, terraform destroy. To list the available commands for execution you can run terraform
command:
terraform
The best place to learn how to use Terraform, deploy, and manage your infrastructure is Terraform docs. There are a lot of providers and services you can manage with it.