TerraformPilot

Terraform

How to Install Terraform on Debian 13 Trixie - Complete Step-by-Step Guide

Step-by-step guide to install Terraform on Debian 13 Trixie. Install HashiCorp Terraform using apt, verify the installation, and configure your first project.

LLuca Berton2 min read
How to Install Terraform on Debian 13 Trixie - Complete Step-by-Step Guide

Introduction

#

Terraform is the industry-standard Infrastructure as Code (IaC) tool for provisioning and managing cloud resources. This guide shows you how to install Terraform on Debian 13 Trixie in under 5 minutes.

Prerequisites

#

Before you begin, make sure you have:

  • A Debian 13 Trixie system (physical or virtual machine)
  • Root or sudo access
  • An active internet connection
  • A terminal/shell session

Install Terraform on Debian 13 Trixie

#

Step 1: Add the HashiCorp Repository

#

HashiCorp provides official packages for major Linux distributions. Using the official repository ensures you always get the latest stable version with security updates.

sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
 
wget -O- https://apt.releases.hashicorp.com/gpg | \
  sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
 
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-get update && sudo apt-get install terraform

Step 2: Verify the Installation

#

After installation, verify that Terraform is available:

terraform -version

You should see output similar to:

Terraform v1.12.x
on linux_amd64

Step 3: Enable Tab Completion (Optional)

#

Enable shell autocompletion for faster workflow:

terraform -install-autocomplete

Restart your shell or run source ~/.bashrc to activate.

Alternative: Install from Binary

#

If you prefer not to use a package manager, you can download the binary directly:

# Download the latest version
TERRAFORM_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | grep -oP '"current_version":"\K[^"]+')
wget "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
 
# Extract and install
unzip "terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
sudo mv terraform /usr/local/bin/
rm "terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
 
# Verify
terraform -version

Alternative: Install with tfenv (Version Manager)

#

tfenv lets you install and switch between multiple Terraform versions — useful when working on projects that require different versions:

git clone --depth=1 https://github.com/tfutils/tfenv.git ~/.tfenv
echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
 
# Install latest Terraform
tfenv install latest
tfenv use latest
terraform -version

Your First Terraform Project

#

Now that Terraform is installed, create your first configuration:

mkdir ~/terraform-demo && cd ~/terraform-demo

Create a file called main.tf:

terraform {
  required_providers {
    local = {
      source  = "hashicorp/local"
      version = "~> 2.0"
    }
  }
}
 
resource "local_file" "hello" {
  content  = "Hello from Terraform on Debian 13 Trixie!"
  filename = "${path.module}/hello.txt"
}

Run:

terraform init
terraform plan
terraform apply -auto-approve
cat hello.txt

You should see: Hello from Terraform on Debian 13 Trixie!

Upgrade Terraform

#

To upgrade Terraform to the latest version in the future:

sudo apt-get update && sudo apt-get upgrade terraform

Uninstall Terraform

#

If you need to remove Terraform:

sudo apt-get remove terraform

Troubleshooting

#

Command not found

#

If terraform is not found after installation:

# Check if it's in your PATH
which terraform
 
# If installed via binary, ensure /usr/local/bin is in PATH
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Permission denied

#
# Ensure the binary is executable
sudo chmod +x /usr/local/bin/terraform

GPG key errors (apt)

#
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

Next Steps

#

Now that Terraform is installed on Debian 13 Trixie, continue your learning journey:

Conclusion

#

You've successfully installed Terraform on Debian 13 Trixie. With Terraform, you can now define, provision, and manage infrastructure across AWS, Azure, GCP, and 3,000+ providers using declarative configuration files.

Install Terraform on other Linux distributions:

Related: Fix the Terraform inconsistent dependency lock file error — quick fix for this common issue.

#Terraform#Linux#Installation

Share this article