Installing and pinning Terraform and OpenTofu

Beginner · 3 min

Install the binary, check it against the published checksum, then pin the CLI version in code so every laptop and CI runner runs the same Terraform or OpenTofu.

Before thisWhy Terraform, and where it fits among IaC tools

Jeff Brown Tech · 28 min · from 3:55

Installing and pinning Terraform and OpenTofu

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Jeff Brown TechReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Terraform ships as one static binary in a zip. Installing it means putting that file on your PATH, and a checksum file lets you verify the download.
  • Terraform and OpenTofu are separate binaries, `terraform` and `tofu`, with separate version numbers.
  • `required_version` in the `terraform` block makes the CLI refuse to run if it is the wrong version. This works in OpenTofu too.
  • A version manager such as tfenv or tenv, with a version file in the repo, makes the pin automatic on every machine.

Two laptops, two behaviours

A team of four starts a project. Ana has Terraform 1.14 from a package manager two years ago. Bo installed the newest release last week. Bo applies a change, Terraform writes state in a newer format, and Ana’s next plan stops with an error about state written by a later version. Nobody did anything wrong. They just did not agree on which binary to run.

Two fixes together prevent this: install the binary in a way you can repeat, and write the version you expect into the repository.

What installing actually is

Terraform is a single compiled program. HashiCorp publishes it as a zip per operating system and CPU at releases.hashicorp.com, next to a SHA256SUMS file. I downloaded the macOS arm64 build of 1.17.2 and checked it. I did not run the binary. Here is what I did:

$ curl -sLO https://releases.hashicorp.com/terraform/1.17.2/terraform_1.17.2_darwin_arm64.zip
$ curl -sLO https://releases.hashicorp.com/terraform/1.17.2/terraform_1.17.2_SHA256SUMS
$ shasum -a 256 -c <(grep darwin_arm64 terraform_1.17.2_SHA256SUMS)
terraform_1.17.2_darwin_arm64.zip: OK
$ unzip -l terraform_1.17.2_darwin_arm64.zip
  Length      Date    Time    Name
    4950  11-11-2026 16:32   LICENSE.txt
123486000  11-11-2026 16:32   terraform

The zip holds one 123 MB program and a licence. “Installing” is copying terraform to a directory on your PATH. Package managers such as Homebrew, apt and winget do the same with extra steps. The SHA256SUMS file is itself signed. HashiCorp lists a .sig file beside it, but there is no gpg on this machine, so I checked only the hash and not the signature. A hash from the same server only guards against a corrupt download. The signature is what guards against a tampered one.

OpenTofu works the same way, as the binary tofu. I asked GitHub for its latest release, and the assets include .sig and .gpgsig signature files for each package. The OpenTofu install page lists Homebrew, Linux packages, Snap, a container image and a standalone binary.

Pinning in code

Put the expectation in the repository, in the terraform block. Written from the Terraform and OpenTofu docs. I did not run it, since there is no Terraform here:

terraform {
  required_version = ">= 1.9, < 2.0"
}

If the running CLI does not satisfy that, it prints an error and exits without doing anything. Both tools read the terraform block, so one file can serve either. The constraint syntax is the same one used for providers, covered in version constraints and the lock file. To see how it behaves against the two tools’ numbers, I wrote a small evaluator of the documented operators and tried it with each tool’s current version:

terraform 1.17.2   required_version >= 1.5, < 2.0 -> ok
terraform 1.17.2   required_version ~> 1.13.0    -> REFUSED
tofu      1.13.10  required_version >= 1.5, < 2.0 -> ok
tofu      1.13.10  required_version ~> 1.13.0    -> ok
tofu      1.13.10  required_version = 1.17.2     -> REFUSED

Notice the last row. A module that says >= 1.14 works on Terraform 1.17 and fails on OpenTofu 1.13, even though nothing in it is Terraform-specific. If you want a module usable by both, pick a floor that both have passed, such as >= 1.5, and test on both.

The evaluator is my own stand-in for the documented rules, not Terraform’s code, so treat it as an illustration. It is also why I trust the table less for odd corners like pre-release versions.

A version manager makes it automatic

A constraint tells you that you have the wrong version. A version manager gets you the right one. tfenv and tfswitch do this for Terraform, and tenv covers both Terraform and OpenTofu. They read a version file in the repo (tfenv uses .terraform-version) and switch binaries per directory. The OpenTofu install page does not mention tenv, so check its own README for exact behaviour. Rahul Wagh’s video in deeper shows tfenv installing a version and rolling back, from 2022.

A sensible team setup is three lines of discipline:

  • required_version in the root module, with a range that matches what CI runs.
  • A version file or a pinned version in the CI image.
  • A habit of upgrading on purpose, one project at a time. Upgrading Terraform and providers covers that later.

Terraform or tofu on your machine?

Both can coexist: they are different binaries. Use the one your team’s CI runs. If a module needs to support both, the OpenTofu docs say a .tofu file takes precedence over a .tf file of the same name, which lets a module ship tool-specific variants. I only read that in the docs. I did not run it.

About the video

The embed is the “Installing Terraform” chapter, 3:55 to 7:22, of Jeff Brown Tech’s “Terraform for Beginners | Easy Tutorial to Get Started” from November 2025. The rest of that video is used in the next lessons. The install chapter is only about three and a half minutes, so the checksum, required_version and OpenTofu parts above are not in it. It was the newest and clearest install walkthrough I found, from a small channel with a few thousand views. English was judged from the title, channel and English auto-captions.

Where this fits

With a pinned binary in place, write something. The next lesson starts with a configuration that needs no cloud account: your first configuration with local resources.

Check yourself

  1. 01Why pin the CLI version when the lock file already pins providers?

    They pin different things. The lock file fixes provider plugins. `required_version` fixes the Terraform or OpenTofu binary itself, whose newer versions can write state that older ones cannot read.

  2. 02A module says `required_version = ">= 1.14"`. Will it run under OpenTofu 1.13.10?

    No. OpenTofu checks the constraint against its own version number, 1.13.10, and refuses. The two projects number their releases independently.

  3. 03What does verifying the SHA256SUMS file protect you from?

    A corrupted or tampered download. It confirms the zip matches what the publisher listed. To trust the list itself you also check its signature, which I could not do on this machine.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark