Terraform is HashiCorp’s infrastructure-as-code tool that lets you define cloud and on-premises resources in human-readable configuration files that you can version, reuse, and share. This guide installs Terraform on Ubuntu 26.04 LTS and runs a first configuration.

Tested and valid on:

  • Ubuntu 26.04 LTS

Prerequisites

  • Ubuntu 26.04 LTS
  • A user with sudo privileges
  • Cloud provider credentials (AWS, GCP, Azure, etc.) for running plans

Step 1 – Install Required Dependencies

sudo apt update
sudo apt install gnupg software-properties-common -y

Step 2 – Add the HashiCorp GPG Key

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

Step 3 – Add the HashiCorp Repository

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
sudo apt update

Step 4 – Install Terraform

sudo apt install terraform -y
terraform --version

Step 5 – Enable Tab Completion

terraform -install-autocomplete
source ~/.bashrc

Step 6 – Write a First Configuration

mkdir ~/tf-demo && cd ~/tf-demo
cat > main.tf <= 1.0"
  required_providers {
    local = { source = "hashicorp/local" version = "~> 2.0" }
  }
}

resource "local_file" "hello" {
  filename = "${path.module}/hello.txt"
  content  = "Hello from Terraform on Ubuntu 26.04!"
}
EOF

Step 7 – Initialize, Plan, and Apply

terraform init
terraform plan
terraform apply
cat hello.txt

Conclusion

Terraform is installed on Ubuntu 26.04 LTS. Use provider-specific configurations to provision AWS EC2 instances, GCP Compute VMs, Azure resources, or any other infrastructure supported by the Terraform provider ecosystem.