Choose an Official Installation Route for Your OS
If this is your first install, the goal is just one working command. Install the Terraform CLI for your operating system, open a new terminal, and run terraform version. The CLI is the program that reads .tf files and coordinates changes. Providers are separate plugins downloaded later by terraform init; pinning the CLI and pinning those plugins solve two different reproducibility problems. You do not need a cloud account to install or inspect Terraform.
A repository changes hands on a Friday. The new owner clones it, runs terraform plan, and is offered a change that replaces a database. The previous owner runs the same command on the same commit and sees no changes at all. Nothing in the configuration differs. The difference is the toolchain: one laptop has a CLI that a package manager moved forward three weeks ago, and the other still runs the binary someone downloaded in March.
That is the problem this article solves, and it is not "how do I get Terraform". It is "how do I know which Terraform I have, where it came from, and whether the next person will get the same one".
An analogy helps. Stocking a workshop with a measuring instrument is not only about acquiring a ruler. It is about which ruler, from which supplier, checked against which standard, and written down so the next shift can trust it. A ruler that is two percent short is worse than no ruler, because everyone builds to the wrong length with confidence.
Terraform makes this easy to overlook because installing it looks trivial. The CLI is a single executable. There is no installer service, no daemon, no runtime to keep patched, and no admin console. "Installation" means putting one binary somewhere your shell will find it, and knowing which binary wins when several exist. That simplicity is a gift and a trap: the tool leaves no trace of where it came from unless you write one down.
The vendor's install page lists the release it currently supports — 1.17.1 when this was checked on 5 November 2026 — and offers per-platform archives alongside package-manager instructions. Three families of route are worth distinguishing.
Windows. The supported route on the official page is the ZIP archive, published for windows_amd64, windows_arm64 and windows_386. Unzip it into a directory you control, add that directory to your user PATH, and open a new terminal, because a PATH change does not reach shells that are already running. Chocolatey, winget and Scoop packages exist and are convenient, but the vendor's install page does not list them as a supported route. If you use one, record the package publisher and verify the binary yourself: a package manager's signature covers the package it built, not necessarily the archive the vendor published.
macOS. There are two routes: the vendor's Homebrew tap (brew tap hashicorp/tap, then brew install hashicorp/tap/terraform) or the darwin_amd64 / darwin_arm64 archive. Run uname -m before choosing; on Apple silicon, arm64 is native and amd64 runs under Rosetta translation with a performance cost. The tap is published by HashiCorp. The terraform formula in homebrew-core is separately maintained and can lag or be compiled differently, which matters precisely when you are comparing version strings between machines.
Linux. The HashiCorp apt and dnf/yum repositories provide signed packages that the operating system's package manager tracks. The archives provide an exact build that you place yourself. For long-lived servers the repository is usually the better default, because patching becomes part of the same workflow as the rest of the system. For a CI base image or a machine you must reproduce exactly, the archive plus a checksum is easier to reason about.
None of these is "the correct" route. They differ in where verification happens and who owns the upgrade. Figure 1 reduces the choice to the questions that actually change the answer.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
A["Need the terraform binary on this machine"] --> B{"Which operating system?"}
B -->|"Windows"| C["Official ZIP for windows_amd64 or windows_arm64"]
B -->|"macOS"| D{"Homebrew already in use?"}
B -->|"Linux"| E{"apt or dnf manages this host?"}
D -->|"yes"| F["brew install hashicorp/tap/terraform"]
D -->|"no"| G["Official ZIP for darwin_arm64 or amd64"]
E -->|"yes"| H["HashiCorp apt or dnf repository"]
E -->|"no"| I["Official ZIP for linux_amd64 or arm64"]
C --> J["Note the exact version and architecture"]
F --> J
G --> J
H --> J
I --> J
J --> K{"Digest and signature verified?"}
K -->|"no"| L["Stop: quarantine the archive"]
K -->|"yes"| M["Put one binary first on PATH"]
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class B,D,E,K primary;
class C,F,G,H,I,J secondary;
class M,J ok;
class L danger;
Figure 1 is a decision tree, but the final verification decision is the one that matters. The route is reversible; using an unverified binary is not, because by the time a wrong build shows a strange plan you have already trusted its output.
Figure 2 draws the same path as a boundary. The vendor publishes three artifacts. Everything to the right of the dashed line is your responsibility, and there are exactly three checkpoints between a download and a command you can defend.
The table compares the routes a small team actually chooses between. Read the fourth column carefully: it is the part people skip, and it is the part that decides whether a version string means anything.
| Route | Best for | How updates arrive | What you verify | Trade-off |
|---|---|---|---|---|
| Vendor archive | Windows by default; any OS needing an exact build | You download again; nothing moves on its own | SHA-256 against SHA256SUMS, plus the signature over that list | Fully explicit, but PATH and upgrades are manual |
| HashiCorp apt or dnf repository | Linux servers and CI base images | The package manager pulls the newest published package | The repository key, then the exact package version you pin | Fleet patching is easy; an unattended upgrade moves the CLI |
| Homebrew tap | macOS developer laptops | brew upgrade moves the formula | Tap provenance and the formula's own checksum | Fast to adopt; laptops drift between upgrades |
| Version manager | Repositories that need different versions side by side | Reads a committed version file for the directory | The manager's download, then terraform version | Reproducible switching; one more tool to trust |
| Container image | Ephemeral CI runners | A new tag or digest | The image digest and its registry signature | Exact per digest, but not a desktop installation |
A team can legitimately use three rows at once: archives in CI, the tap on laptops, the system repository on servers. What it cannot do is leave the choice implicit. The next section turns "which binary am I running" from a guess into a command.
Verify the Binary and Inspect the CLI
Verification is not a ceremony performed once at install. It answers three questions that come back every time a plan surprises someone: which binary actually ran, how do I know it is the build I intended, and how do I prove both later without relying on memory.
The first answer is one command. In a directory with no configuration, terraform version prints two lines: the CLI release, and the platform the binary was built for. Inside an initialised module it adds a third block, listing the providers selected in .terraform.lock.hcl, because the command reads the configuration it finds. That distinction matters: the first two lines describe the program, and the third describes the project. When a colleague's output shows a different provider line, the CLI may be identical and the lock file may not.
terraform version -json returns the same facts as an object with terraform_version, platform, provider_selections and terraform_outdated. That is the form to capture in a lab record or compare in a pipeline, because parsing prose breaks the first time the wording changes. terraform -help lists the commands your build knows, and terraform plan -help lists the flags. Those lists are how you check whether an installed version supports something you read about; release notes describe a version, and the binary in front of you is the one that will run.
The second answer depends on the route, and the difference is worth stating precisely because the two are often conflated.
With a package manager, verification happens through repository metadata. apt and dnf check a signature over the package index, and the index carries the package hashes. You verify the repository key once, when you add the repository, and from then on you are trusting the vendor's repository together with the operating system's package tooling. That is a reasonable trust decision, but it is a different act from hashing an archive by hand.
With a direct archive, the trust chain runs from SHA256SUMS.sig to SHA256SUMS to your file. The signature over the checksum list is what makes the list trustworthy; a hash fetched from the same server as the archive detects corruption but not substitution. Verify the detached signature with HashiCorp's published key, then compare your archive's digest with the line for your exact filename. Both steps take seconds and together they answer "is this the vendor's build" rather than "did this arrive without bit rot".
The panel below shows the commands a learner can adapt. Replace the bracketed values with the release you actually downloaded; the commands do not assume a version.
Step 1 deserves a note on each OS. On macOS and Linux, command -v terraform prints the path the shell will execute, and type -a terraform lists every match in order, which explains the classic "I upgraded but the old version still runs" — an older binary sits earlier on PATH. On Windows, where.exe terraform does the same for cmd.exe; in PowerShell, prefer Get-Command terraform | Select-Object Source, because where there is an alias for Where-Object and will not do what you expect.
Figure 3 turns the direct-download path into a flow with its failure branches. Each "no" either stops you or sends you back a step; none is safely ignorable. A digest mismatch means the file is not the file the list describes. A bad signature means the list itself cannot be trusted. A platform mismatch usually means a second binary is shadowing the one you just installed.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
A["Archive and SHA256SUMS on disk"] --> B["Compute SHA-256 of the archive"]
B --> C{"Matches the line for this filename?"}
C -->|"no"| D["Reject: corrupt or substituted archive"]
C -->|"yes"| E["Verify SHA256SUMS.sig with the vendor key"]
E --> F{"Good signature?"}
F -->|"no"| G["Reject: the checksum list is not authentic"]
F -->|"yes"| H["Extract and place terraform on PATH"]
H --> I["terraform version reports the release and platform"]
I --> J{"Platform matches this machine and the record?"}
J -->|"no"| K["Fix PATH: an older binary is being resolved first"]
J -->|"yes"| L["Accept and record version, source and digest"]
K --> I
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class C,F,J primary;
class A,B,E,H,I secondary;
class L ok;
class D,G,K danger;
What verification does not prove is equally important. It does not prove the release is free of bugs. It does not prove that the provider Terraform installs later is the same build your colleague has; that is the lock file's job, and the "signed by HashiCorp" line that init prints refers to the provider package, not to the CLI. And it does not prove that the state file was written by this version. Each of those is a separate control, and the next section separates the one that is most often confused with installation.
Pin the CLI Independently of Provider Versions
A Terraform project has three separate version controls. The example below uses the CLI version from this series, a compatible AWS provider range, and a registry module range. It is a configuration example, not a command to create infrastructure: terraform plan needs AWS credentials, and terraform apply can create real AWS resources and charges.
Read the file from top to bottom. required_version belongs to the Terraform CLI: the exact = 1.17.1 constraint accepts that release only. A terraform init or later operation that loads this configuration stops if the binary on your PATH does not match. terraform version only reports the binary; it neither selects nor installs one. Install the required release yourself or use an optional version manager such as tfenv or tenv.
The provider block names a plugin by its source address, hashicorp/aws, and accepts versions allowed by ~> 6.28 (6.28 or newer within the 6.x series). On the first terraform init, Terraform chooses a matching provider and records the selected version and checksums in .terraform.lock.hcl. Commit that file. Later inits reuse the recorded selection unless you deliberately upgrade it. The constraint says what is acceptable; the lock file remembers which acceptable provider was selected.
The module block points to a separately versioned collection of Terraform configuration. ~> 6.8 accepts module releases from 6.8 up to, but not including, 7.0. Terraform resolves a matching registry module during init, but .terraform.lock.hcl does not remember that module selection. If the team needs the same module release each time, change the module constraint to an exact version such as "6.8.0" and review that upgrade in source control. A local module has no version argument; for a Git module, use a reviewed immutable commit ref rather than a moving branch name.
These constraints are combined across the root and child modules: if their CLI requirements or provider ranges have no compatible version in common, Terraform stops instead of guessing. Each control has a different job, so changing one does not update the others.
A range is often the right CLI policy for a shared module. required_version = ">= 1.9, < 2.0" accepts supported Terraform 1.x versions from 1.9 onward instead of forcing every consumer onto one patch release. The pessimistic operator sits between an exact pin and a broad range: ~> 1.17 allows compatible later 1.x releases, including 1.18, while ~> 1.17.0 stays within 1.17.x. Neither expression is an exact pin.
Version managers are an optional third layer. tfenv reads a .terraform-version file in the repository and installs or switches to the release it names. tenv does the same and also manages OpenTofu and Terragrunt, which is useful if a team runs both. asdf reaches Terraform through a plugin. In each case the version file is committed next to the configuration, so the pin travels with the code instead of living in someone's shell history.
They are not mandatory, and they are not free. A version manager is another binary you install, another download path you verify once, and another thing to keep working on a new laptop. It earns its place when you maintain more than one Terraform version at a time, or when onboarding takes long enough that "install the right one" is a recurring support ticket. A single verified binary per machine plus a written record is a perfectly good answer for a team with one pin.
CI is where the dials most often disagree. Three habits close the gap:
- Pin the exact version in the pipeline, either in the image digest or in the setup step's version input. A floating
latestturns an unrelated pull request into an upgrade test. - Assert it inside the job. Capture
terraform version -jsonand compareterraform_versionwith the expected string; fail on a mismatch. This catches a base image that changed under you, which a pipeline configuration file alone cannot. - Make init refuse to rewrite the lock file.
terraform init -lockfile=readonlyverifies the recorded selections and checksums without adding new ones, so an accidental upgrade becomes a failed job rather than a surprise commit.
TF_IN_AUTOMATION=1 and -input=false belong in the same job. The first suppresses advice meant for humans, and the second makes a missing variable fail loudly instead of waiting for input that will never arrive. Neither affects versions; both make version problems easier to see.
Understand What the Dependency Lock File Records
.terraform.lock.hcl is the most misunderstood file in a Terraform repository. It is small, generated, and usually committed for a reason people state imprecisely — "it pins our providers" is close, but the interesting part is what it leaves out.
Init writes one entry per selected provider. Each entry carries the provider address, the selected version, the constraints that produced the selection, and a set of hashes. The h1: hashes describe the package contents in a way that is independent of packaging; the zh: hashes describe the published zip archives, one per platform variant. Together they let a later init verify a download on a different operating system without anyone re-hashing by hand.
The behaviour that follows is narrow and useful. If a selection already exists, init re-selects that version even when a newer one satisfies the constraint; -upgrade is the deliberate override. If a downloaded package matches none of the recorded hashes, init stops with a checksum error instead of installing it. If you add a platform, init may append hashes for it — and under -lockfile=readonly it will instead fail, which is the point. The fix is to run terraform providers lock with the platforms you need on a developer machine and commit the result.
The lock file records provider selections and their hashes. It does not record remote module selections, the CLI version, or the backend. Commit it to make provider installs reproducible, then pin modules and the CLI separately, because nothing in this file will do either job for you.
The omission that causes the most surprise is modules. A module block pointing at the registry with version = "~> 5.0" is resolved at every init, and the lock file has no entry for it. Two machines can therefore agree perfectly on providers and still download different module code. If reproducibility matters, pin the module to an exact version or a Git ref, and treat that pin as part of the change you review. A branch name in a Git source is not a pin either; the commit it points to moves.
Figure 4 shows the difference a committed lock file makes across three machines, and the band underneath marks the layer it cannot cover.
Two practical rules follow. Never hand-merge the hash lists: take one side of a conflict, run init, then run terraform providers lock for the platforms the team uses, and commit the regenerated file. And never edit a version inside it to "fix" a build; that is an upgrade wearing a disguise, and it belongs in its own reviewed change.
Keep Upgrades Deliberate and Reversible
An upgrade is three decisions wearing one commit. The CLI, a provider, and a module can each move independently, and bundling them makes a failure ambiguous: when the plan changes, you cannot tell which dial did it.
Take them one at a time. Read the changelog for the versions you are crossing, not just the newest entry, and look for the three things that actually break plans: removed arguments, provider schema changes that force replacement, and renamed module inputs. A deprecation warning is cheap to fix now and expensive to discover during an incident.
Then run the change somewhere disposable. Compare plans, not just exit codes: a provider upgrade can leave the current plan identical and still change how a future apply behaves, because the difference lives in code paths your current configuration does not exercise. Where the provider publishes one, read its upgrade guide for the versions you crossed.
Rollback deserves its own paragraph because it is where confidence is usually misplaced. For providers, reverting the lock file and running init restores the previous selection, and that is enough if the newer version did not write state the older one cannot read. Provider schema versions move forward; a downgrade after an apply can fail with a state compatibility error rather than quietly working. For the CLI, the state file records the version that wrote it, so rolling the binary back after an apply may be refused outright. For modules, reverting the constraint or ref and re-running init is usually clean, since module code does not live in state. The cheap rollback window is therefore before the apply, which is another argument for reviewing a plan rather than applying from a terminal you will not remember.
The habit that makes all of this tractable is a toolchain record: one short file in the repository that names the OS, the architecture, the exact CLI version, the install route, the provider versions from the lock file, and the date someone verified them. It is not documentation for its own sake. It is the difference between "it worked last month" and a reproducible claim.
Record the toolchain
Execution status: design-only. The author did not run this on your machine; you perform it and keep the output. The point is the record, not the installation.
Prerequisites. A machine you are allowed to install software on, network access to the vendor's release host or package repository, a scratch directory, and a small Terraform configuration with at least one provider — the local-file lab from the previous article works and costs nothing.
- Install the CLI by one route from the table. Write down which route, and why you chose it over the other two that applied to your OS.
- Run
terraform versionandterraform version -json. Save the JSON, or the two lines if you prefer; either is acceptable evidence as long as it is the real output. - Capture the platform independently:
uname -srmon macOS or Linux, or$env:PROCESSOR_ARCHITECTUREand the OS version in PowerShell. The architecture in the record must match the architecture in the version output. - Run
command -v terraform(orwhere.exe terraformon Windows) and record the full path. If the path is not the one you installed to, you have found a shadowed binary before it found you. - If you used a direct archive, verify it: hash the file, compare with the line in
SHA256SUMS, and verifySHA256SUMS.sig. Record the source of the expected digest, not just the digest. - In the configuration directory, run
terraform init, thenterraform providers. Copy each provider address and selected version into the record. If.terraform.lock.hclwas created, note the commit that contains it. - Run
terraform providers lock -platform=linux_amd64 -platform=darwin_arm64and inspect the diff. If your laptop is the only machine you work on, the file gains hashes for platforms you do not run; that growth is what stops CI from rewriting the lock later. - Test a deliberate provider upgrade: raise its constraint by one patch version, run
terraform init -upgrade, and read the lock file diff. Then restore the previous lock file, run init again, and confirm the earlier selection returns. The second init is your rollback rehearsal. - Break it on purpose: put an older
terraformearlier onPATHand watchterraform versionchange. Then runterraform init -lockfile=readonlyand confirm that a missing platform hash fails the job instead of being silently added.
Expected observation. A finished record names six things — OS, architecture, CLI version, install route, provider versions, verification date — and someone else can reproduce the install from it without asking you a question. The upgrade rehearsal produces a lock file diff you can read, and the rollback returns the previous selection without touching state.
Failure checks. A digest mismatch means the archive is not the published one; stop. A signature failure means the checksum list cannot be trusted; stop. A terraform version that disagrees with the installed path means a shadowed binary. An init that fails on required_version means the CLI and the configuration disagree, which is the constraint doing its job.
Cost dimensions. Disk and download only. The CLI archive is tens of megabytes, providers are cached under .terraform/, and the record itself is a few kilobytes. No cloud account, credential or billable resource is involved.
Cleanup. Delete the scratch directory, which removes .terraform/, the lock file copy and any saved plans. Uninstall the CLI only if you installed it for this exercise; otherwise keep it and keep the record.
References (checked 5 November 2026): Install Terraform, verify a HashiCorp binary, dependency lock file, terraform providers lock, and CLI version constraints.
Next in the Series
In Read Terraform Configuration: Blocks, Files and the Root Module, we'll explore Understand the native HCL structure and the directory that Terraform treats as one configuration.