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
sudo apt update
sudo apt upgradeEnsure 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.
sudo apt-get update && sudo apt-get install -y gnupg software-properties-commonInstall the HashiCorp GPG Key
wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/nullAdd 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.
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.listDownload the package information from HashiCorp.
sudo apt update
sudo apt-get install terraformEnable tab completion
terraform -install-autocompleteHow is this guide?