This is a small note, but it is exactly the kind of small note I end up reusing.

When I install Terraform on a fresh Ubuntu host, I usually want two things:

  • the official HashiCorp package source
  • the ability to pin a specific version instead of blindly taking whatever is newest

Add the HashiCorp Apt Repository

1
2
3
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) 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

Check Available Versions

Before installing, inspect what versions the repository is offering:

1
sudo apt-cache madison terraform

That is the step I especially like keeping in the note, because it makes version pinning feel intentional instead of improvised.

Install a Specific Version

In this case, I installed:

1
sudo apt install terraform=1.10.4-1

Why This Post Exists

This is not a Terraform tutorial. It is just the shortest useful record of how I installed a pinned version on Ubuntu 24.04 without guessing the repository setup from memory.