How to Upgrade Terraform to a Specific Version

3 min read

Sometimes you need a specific Terraform version — maybe a module requires it, or you’re matching what your team uses. The default package managers don’t always have the version you need, so the most reliable way to upgrade Terraform to a specific version is to download the binary directly from HashiCorp.

The examples here are run on WSL2 Ubuntu in Windows, but they work the same on any Ubuntu or Linux system.

Check Your Current Version

Before upgrading, check what you’re running now:

terraform -version

If Terraform isn’t installed yet, you’ll get command not found — that’s fine, the steps below work for fresh installs too.

Method 1: Manual Install (Direct Binary)

This is the straightforward way. You download the exact version you want from HashiCorp, replace the old binary, and you’re done.

1. Find the version you need

Browse the Terraform releases page to find your target version. You can also check the GitHub releases for changelogs.

2. Download and install

Replace the version number in the commands below with the one you need. This example installs 1.14.6 for 64-bit Linux (linux_amd64):

TERRAFORM_VERSION="1.14.6"
wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip
sudo mv terraform /usr/local/bin/
rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip
  • wget — downloads the zip from HashiCorp’s release server
  • unzip — extracts the terraform binary from the zip
  • sudo mv — moves it to /usr/local/bin/ so it’s in your PATH
  • rm — cleans up the downloaded zip

If you don’t have unzip installed, grab it first: sudo apt install -y unzip

For ARM-based systems (like Graviton EC2 instances or Apple Silicon with Linux), use linux_arm64 instead of linux_amd64.

3. Verify the version

terraform -version
Terraform v1.14.6
on linux_amd64

Method 2: Use tfenv (Recommended for Teams)

If you work on multiple projects that need different Terraform versions, the manual approach gets annoying fast. tfenv is a version manager for Terraform (similar to nvm for Node.js or pyenv for Python) that lets you install and switch between versions with a single command. It’s maintained as an open-source project on GitHub.

Install tfenv

git clone https://github.com/tfutils/tfenv.git ~/.tfenv
echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Install a specific version

tfenv install 1.14.6
tfenv use 1.14.6

Switch between versions

tfenv install 1.10.3
tfenv use 1.10.3
terraform -version

You can also pin a version per project by creating a .terraform-version file in your project root:

echo "1.14.6" > .terraform-version

When you cd into the project directory, tfenv automatically uses the version specified in that file. This is really useful when different repos need different versions — you don’t have to remember to switch manually.

Useful tfenv commands

Command What It Does
tfenv list Shows all installed versions
tfenv list-remote Shows all available versions from HashiCorp
tfenv install latest Installs the latest stable version
tfenv use latest Switches to the latest installed version
tfenv uninstall 1.10.3 Removes a specific version

Pin the Version in Your Terraform Config

Regardless of which installation method you use, always set a required_version constraint in your Terraform configuration. This prevents anyone on the team from accidentally running the wrong version against your infrastructure:

terraform {
  required_version = ">= 1.14.0, < 2.0.0"
}

If someone runs terraform plan with a version outside this range, Terraform exits with an error instead of potentially breaking your state file.

Conclusion

For a quick one-off upgrade, download the binary from HashiCorp and drop it in /usr/local/bin/. If you’re juggling multiple projects with different version requirements, use tfenv — it handles the switching for you. Either way, always set required_version in your Terraform config so the wrong version can’t run against your infrastructure.

If you’re setting up Terraform for the first time on WSL, check out How to Configure Terraform on Windows 10 WSL Ubuntu for AWS Provisioning. You’ll also want the AWS CLI installed if you’re provisioning AWS resources.