LogoDocumentation

Terraform

Learn how to install Terraform for Infrastructure as Code (IaC) automation

What is Terraform?

Terraform is an open-source Infrastructure as Code (IaC) tool developed by HashiCorp. It allows users to provision, manage, and automate infrastructure across multiple cloud providers and on-premises environments using a declarative configuration language.

With Terraform, infrastructure is defined in code, making it scalable, repeatable, and version-controlled. It supports major cloud platforms like AWS, Azure, Google Cloud, and Kubernetes, enabling teams to efficiently manage resources and improve operational consistency.

Prerequisites

  • Virtual Machine running Ubuntu 22.04 or newer

Update Package Repository and Upgrade Packages

Bash
sudo apt update
sudo apt upgrade

Ensure that your system is up to date and you have installed the gnupg, software-properties-common, and curl packages installed. You will use these packages to verify HashiCorp's GPG signature and install HashiCorp's Debian package repository.

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

Install the HashiCorp GPG Key

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

Add the official HashiCorp repository to your system. The lsb_release -cs command finds the distribution release codename for your current system, such as buster, groovy, or sid.

Bash
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

Download the package information from HashiCorp.

Bash
sudo apt update
sudo apt-get install terraform

Enable tab completion

Bash
terraform -install-autocomplete

How is this guide?