Tfenv: The Ultimate Terraform Version Manager for DevOps & IaC Teams
Open-source · v3.2.1 · MIT License

Switch Terraform versions in seconds, not sprints.

Tfenv is a lightweight, fast, dependency-free Terraform version manager. Install any HashiCorp release, pin it per Infrastructure as Code (IaC) project, and eliminate version drift across laptops, CI runners, and production environments.

14KB
Single File Size
0
Dependencies
340+
TF Versions Supported
~/projects/cloud-infra — zsh
cd cloud-infra
tfenv install
[tfenv] Installing Terraform v1.9.5
Verified SHA256 signature
Installed to ~/.tfenv/versions/1.9.5
terraform version
Terraform v1.9.5 on darwin_arm64
GPG VerifiedSecure downloads
0.8s SwitchInstant execution
What is Tfenv

A specialized version manager built specifically for the Terraform CLI.

Tfenv solves the critical challenge of version drift in Infrastructure as Code by reading the version pin from your repository, downloading the matching HashiCorp-signed Terraform binary, and shimming it onto your PATH automatically. No more manual tarballs or "works on my machine" tunnels.

It operates identically on macOS, Linux, and Windows. This guarantees your onboarding documentation, CI/CD pipelines, and pair programming sessions all leverage the exact same IaC tooling surface, ensuring state file integrity and predictable provider behaviors.

  • Version-pinned per directoryUses .terraform-version, .tfenvrc, or environment variable.
  • Signature-verified downloadsValidates HashiCorp GPG signatures before install.
  • Shell-agnosticBash, Zsh, Fish, PowerShell — same behavior everywhere.
  • Offline cacheAlready-downloaded versions never hit the network again.

live_demo.tfenv

zsh — 118×30
tfenv install
# Reading .terraform-version...
1.9.5 found
Downloading terraform 1.9.5
Verifying SHA256SUMS signature
Symlinked to ~/.tfenv/bin/terraform
 
terraform version
Terraform v1.9.5
Three-minute setup

Cross-Platform Tfenv Installation Guide

Three official channels. Pick the one that matches your DevOps workflow — package manager for macOS, direct download for Linux servers, and a quick script for Windows. Or just download the archive directly.

Download Tfenv .zip Archive

macOS Terraform Version Manager Setup

The fastest path on a Mac. Tap the official formula and you're done in under ten seconds.

# Add the tap
brew tap tfutils/tfenv

# Install
brew install tfenv

Linux Tfenv Automation Setup

Works on Ubuntu, Debian, Alpine, Arch, Fedora. Anywhere a POSIX shell exists.

curl -sSfL https://tfenv.org/install.sh | sh

# Or manual download:
unzip master.zip -d ~/.tfenv
echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bashrc

Windows IaC Version Control Setup

Installs into %USERPROFILE%\.tfenv. Works inside PowerShell, Windows Terminal, and WSL.

# PowerShell as admin
Invoke-WebRequest -Uri https://tfenv.org/install.ps1 -OutFile install.ps1
.\install.ps1

# Add to PATH manually if needed
Why teams pick Tfenv

Advanced Features for Terraform Version Control

From a single contributor to a 200-person platform engineering team, Tfenv scales without ceremony. It stays out of your way until you ask for it, providing robust Infrastructure as Code automation.

Secure Terraform CLI Downloads & GPG Verification

Every binary is checked against HashiCorp's published SHA256SUMS and GPG signature. Tampered artifacts are refused, ensuring your Infrastructure as Code remains secure and compliant across all deployment environments.

Instant Terraform Version Switching

Cd into a project and Tfenv reads the pin file in milliseconds. No re-installs, no waiting, no re-shimming.

Air-Gapped Infrastructure as Code Environments

Point TFENV_REMOTE at an internal mirror or S3 bucket and Tfenv will pull from there. Perfect for regulated environments.

Team-Synced Terraform Version Control

Commit .terraform-version and everyone on the team runs the same Terraform. Drift becomes impossible by design.

CI/CD Pipeline Caching for Terraform

Automate CI pipelines easily. Tfenv caches downloaded versions between runs to shave minutes off pipelines.

Featherweight DevOps Version Manager

A single shell script and a handful of helpers. No Node, no Python runtime, no background daemon, no telemetry phoning home.

The four-step loop

The Standard Tfenv DevOps Workflow

Most users run exactly four commands per project, ever. The rest of the time, Tfenv is silent, ensuring smooth Infrastructure as Code operations.

Pin Terraform Version

Establish strict version control by committing a .terraform-version file to your IaC repository.

echo "1.9.5" > .terraform-version

Install Terraform CLI On Demand

Run tfenv install with no arguments. It reads the pin and downloads the correct HashiCorp binary.

tfenv install

Execute Infrastructure as Code

The terraform command on your PATH now points at the pinned release.

terraform plan

Switch Terraform Projects Instantly

Cd into another repo. Tfenv re-reads the pin and swaps the shim instantly without manual uninstall.

cd ../billing-api
Reference

Essential Tfenv Commands & CLI Reference

The CLI surface is intentionally small. Eight verbs cover installing, listing, switching, and uninstalling Terraform versions. Below is the full reference for DevOps automation and IaC version management.

installuselistuninstallversion-nameinitpinlist-remote
tfenv install
Install the version pinned in .terraform-version, or latest if none.
CORE
tfenv install [version]
Install a specific Terraform release, e.g. 1.9.5 or latest:^1.9.
CORE
tfenv use [version]
Switch the active shim to a previously installed version.
CORE
tfenv list
List all locally installed Terraform versions, marking the active one.
CORE
tfenv list-remote
Show every release HashiCorp has ever published, including pre-releases.
CORE
tfenv uninstall [version]
Remove a version from the local cache. The active version is protected.
CORE
tfenv pin [version]
Write the current or specified version into .terraform-version.
UTIL
tfenv version-name
Print the currently active Terraform version and its source.
UTIL
tfenv update
Pull the latest Tfenv self-update from the upstream repository.
UTIL
Live catalog

HashiCorp Terraform Release Catalog

Tfenv tracks every HashiCorp release going back to v0.10. Old versions, pre-releases, and the latest stable are all one command away, ensuring complete Infrastructure as Code lifecycle support.

Stable Pre-release Cached
340+ releases · refreshed daily
v1.9.5 · Sept 24, 2024
CURRENT
~/.tfenv/versions/1.9.5
v1.9.4 · Sept 04, 2024
STABLE
cached · 64MB
v1.9.3 · Aug 21, 2024
STABLE
cached · 64MB
v1.10.0-rc1 · Oct 02, 2024
PRE-RELEASE
remote only
v1.8.5 · Jul 17, 2024
STABLE
cached · 62MB
v1.7.5 · May 29, 2024
STABLE
cached · 60MB
v1.6.6 · Apr 03, 2024
STABLE
cached · 58MB
v1.5.7 · Jan 18, 2024
STABLE
cached · 56MB
v0.12.31 · Mar 31, 2021
LEGACY
remote only
In the wild

Real-World Use Cases for Tfenv

From local laptops to air-gapped production floors — same tool, same flags, same outcomes. Tfenv adapts to any DevOps or Infrastructure as Code environment.

Developer workstations

Day-One Terraform Developer Onboarding

New engineer clones your repo, runs make bootstrap, and Tfenv installs the exact Terraform the team uses. No wiki hunting, no Slack thread archaeology, just immediate IaC productivity.

  • Reads .terraform-version on cd
  • Skips re-download if cached
  • Surfaces upgrade warnings
CI / CD runners

Reproducible Terraform CI/CD Pipelines

Cache ~/.tfenv between jobs and your terraform plan step drops from 90 seconds to under 5. Pin once, run thousands of times with perfect IaC state consistency.

  • Cache key per .terraform-version
  • Works with automated CI runners
  • Headless — no interactive prompts
Air-gapped environments

Air-Gapped Terraform Mirror Mode

Point TFENV_REMOTE at your artifact server. Tfenv downloads from there and verifies against your internal GPG key. No public internet required for secure Infrastructure as Code deployments.

  • Set TFENV_REMOTE env var
  • Custom TFENV_GPG_KEYRING
  • Logging friendly to audit teams
Multi-tenant SRE

Per-Tenant Terraform Version Pinning

Platform teams running Terraform for multiple customers can pin different versions per tenant directory. Switching contexts becomes a cd, not a reinstall, streamlining multi-tenant IaC operations.

  • Isolated TFENV_DATA_DIR per tenant
  • Concurrent terraform processes
  • Audit log of every switch
Walkthrough

Tfenv in Action: Terminal Walkthrough

This is the exact sequence you'd run joining a new infrastructure repo. Four commands, three seconds, zero ambiguity. A perfect demonstration of seamless Terraform CLI version management.

~/projects/cloud-infra — zsh — 132×40
1 cd cloud-infra
2Reading .terraform-version...
31.9.5
4 
5 tfenv install
6[tfenv] Installing Terraform v1.9.5
7 Downloaded terraform_1.9.5_darwin_arm64.zip
8 Verified SHA256: 9f1a8c...d4e2
9 Verified GPG signature (HashiCorp Security)
10 Installed to ~/.tfenv/versions/1.9.5
11[tfenv] Symlinked to ~/.tfenv/bin/terraform
12 
13 tfenv use # no-op, already pinned
14[tfenv] Switching to v1.9.5 (already active)
15 
16 terraform init -upgrade
17Initializing the backend...
18Initializing provider plugins...
19Terraform has been successfully initialized!
20 
21 terraform version
22Terraform v1.9.5 on darwin_arm64
Compatibility surface

Operating System & Architecture Compatibility

Tfenv is a POSIX shell script with zero compiled components. If your machine can run a shell, it can run Tfenv, ensuring universal Infrastructure as Code support.

Multi-Architecture Terraform Support

Tfenv seamlessly manages HashiCorp Terraform binaries across five distinct CPU architectures. From Apple Silicon (arm64) MacBooks to AWS Graviton-based EC2 instances, this Terraform version manager automatically detects your system architecture and fetches the correct compiled binary. This guarantees that your Infrastructure as Code deployments run natively, eliminating Rosetta 2 emulation overhead and accelerating IaC execution times across diverse DevOps environments.

amd64arm64arm386ppc64le

macOS Terraform Compatibility

Tfenv provides universal macOS compatibility for both Intel and Apple Silicon architectures, making it the premier Terraform CLI version manager for Mac-based DevOps teams. Whether you prefer managing dependencies through Homebrew formulas or MacPorts ports, installing and updating Tfenv takes less than ten seconds. This ensures your macOS Infrastructure as Code development environment remains perfectly synchronized with your production Linux servers.

12 Monterey13 Ventura14 Sonoma15 Sequoia

Linux Terraform Compatibility

As a lightweight POSIX-compliant shell script, Tfenv runs flawlessly on any glibc-based Linux distribution. Whether your Infrastructure as Code automation runs on Ubuntu, Debian, Fedora, Arch Linux, or minimal cloud images, this dependency-free Terraform version manager integrates perfectly into your existing Linux DevOps workflows without requiring Python, Node.js, or Ruby runtimes.

UbuntuDebianFedoraArch

RHEL Terraform Compatibility

Tfenv is rigorously tested against Red Hat Enterprise Linux (RHEL) 8 and 9, as well as Rocky Linux distributions. This makes it an ideal Terraform version manager for enterprise DevOps teams operating in highly regulated, legacy-heavy environments. It allows platform engineers to securely pin and switch Terraform CLI versions on critical RHEL servers without disrupting system-wide package managers.

RHEL 8RHEL 9Rocky

Containerized Terraform Environments

Integrate Tfenv seamlessly into your Dockerfiles and containerized Infrastructure as Code pipelines. Because it has zero compiled dependencies, it drops perfectly into Alpine Linux, Scratch, and Distroless base images. This enables highly reproducible, ephemeral CI/CD runners that dynamically fetch the exact pinned Terraform version required for each IaC deployment pipeline.

AlpineScratchDistroless

Windows Terraform Compatibility

Tfenv brings robust Terraform CLI version management to Windows developers. It operates natively within PowerShell and Windows Terminal, and integrates perfectly with Windows Subsystem for Linux (WSL2). This flexibility allows hybrid DevOps teams to maintain identical Infrastructure as Code tooling across mixed OS environments, eliminating versioning discrepancies between Windows workstations and Linux servers.

1011WSL2Server 22

Shell Environment Compatibility for IaC

Built strictly to POSIX-compliant standards, Tfenv works harmoniously across Bash, Zsh, Fish, and even PowerShell. This shell-agnostic design ensures that no matter the terminal environment your DevOps engineers prefer, the Terraform version manager initializes instantly and intercepts commands reliably for frictionless Infrastructure as Code execution.

BashZshFishpwsh
By the numbers

Tfenv Performance Benchmarks

Benchmarked against common alternatives on a fresh 2024 M3 MacBook Pro. Lower is better for install and switch times.

0s
Median install time, cached
0KB
Installed footprint, single file
0s
Cold install over gigabit
0
External runtime dependencies
Side by side

Tfenv vs Other Version Managers

Not every tool optimizes for the same thing. Here's an honest comparison so you can pick what fits your Infrastructure as Code stack.

Capability
TfenvRecommended for Terraform
asdf-terraform
Manual tarball
Terraform Install Time (Cold)Clean machine, gigabit network
3.2s
~12s
~8s
Per-Project Terraform PinningAuto-read on cd
GPG Signature VerificationRefuses tampered binaries
Runtime DependenciesNode, Ruby, Python, etc.
None
asdf + plugin
None
Air-Gapped Terraform MirrorCustom remote URL
Manages Other IaC ToolsPolyglot versioning
Footprint on DiskWithout downloaded Terraform versions
14 KB
~3 MB
0 KB
Common questions

Frequently Asked Questions about Tfenv

Explore 25 of the most searched questions about the Tfenv Terraform version manager, categorized by DevOps workflow. Tap any card to expand. Still stuck? The community is fast.

Need human help?

Open a discussion on the Tfenv community portal or join our DevOps chat — most threads get a response within four hours during weekdays.

Browse Guides
How to install the Tfenv Terraform version manager on Linux and macOS?

You can install the Tfenv version manager by downloading the official archive and extracting it into your ~/.tfenv directory, then adding the bin folder to your system PATH. Alternatively, macOS users can install it via Homebrew using brew install tfenv.

What is the correct Terraform version manager installation process on Windows?

On Windows, you can extract the Tfenv version manager into your %USERPROFILE%\.tfenv directory using PowerShell. You must then manually add the .tfenv/bin directory to your Windows PATH environment variables to use the tfenv command for Infrastructure as Code automation.

Does the Tfenv Terraform version manager require external dependencies?

No, Tfenv is designed to be completely dependency-free. It is built as a POSIX-compliant shell script. As long as your system has a standard shell environment (like Bash or Zsh) and curl or wget for downloading HashiCorp binaries, Tfenv will run perfectly.

How can I download the latest Tfenv version manager archive?

You can download the latest master branch directly as a zip archive from the official source. Extract it and place the contents in your target installation directory to start managing your Infrastructure as Code versions.

Is the Tfenv Terraform version manager available via Homebrew?

Yes, Tfenv has an official Homebrew formula. You can install it on macOS by running brew install tfenv. This is the fastest and most maintainable installation method for Mac users managing Terraform CLI versions.

How do I pin a specific HashiCorp Terraform version in my IaC project?

To pin a version, navigate to your Infrastructure as Code project root and run tfenv pin <version>. Alternatively, manually create a .terraform-version file containing the exact version number. Tfenv will automatically use this version whenever you enter the directory.

Can I use Tfenv to manage multiple Terraform versions in a monorepo?

Yes. Tfenv supports monorepos by walking up the directory tree. You can place .terraform-version files in different subdirectories. When you cd into a specific service's folder, Tfenv reads the nearest pin file and switches versions instantly.

What is the .terraform-version file used for in Infrastructure as Code?

The .terraform-version file is a simple text file containing the exact Terraform CLI version your project requires. Tfenv reads this file automatically to download, install, and shim the correct binary without manual intervention.

How do I switch between different Terraform CLI versions using Tfenv?

You can switch versions by running tfenv use <version>. If the version is already installed locally, Tfenv will switch to it immediately. If it is not installed, Tfenv will prompt you to run tfenv install first.

Can the Tfenv version manager install specific Terraform pre-release versions?

Yes, Tfenv can install pre-release versions like alphas, betas, and release candidates. Simply run tfenv install latest:^1.10 or specify the exact pre-release string like tfenv install 1.10.0-rc1.

How do I integrate Tfenv into automated CI/CD pipelines?

To use Tfenv in CI/CD pipelines, add a step to install Tfenv via download, then run tfenv install. To speed up pipelines, cache the ~/.tfenv directory using your CI provider's caching mechanism so binaries are downloaded only once.

Can I cache Terraform versions in GitLab CI pipelines using Tfenv?

Yes, in GitLab CI, you can use the cache keyword with a key pointing to your .terraform-version file. Configure the cache paths to include the ~/.tfenv/versions directory to prevent re-downloading the HashiCorp binaries on every pipeline run.

How to ensure reproducible Terraform deployments in CI with a version manager?

Always commit the .terraform-version file to your repository. This ensures that both local developers and CI/CD runners use the exact same Terraform CLI version, preventing state file corruption and unpredictable provider behaviors.

Does the Tfenv Terraform version manager work in Docker containers?

Yes, Tfenv is lightweight and works perfectly in Docker containers, including Alpine Linux. You just need to install standard shell utilities (bash, curl, tar) in your Dockerfile before running the Tfenv installation script.

What environment variables optimize Tfenv for headless CI runners?

You can set TFENV_TERRAFORM_VERSION to bypass reading the .terraform-version file, and TFENV_AUTO_INSTALL=true to allow Tfenv to automatically download the required version without interactive prompts, which is ideal for CI runners.

How does Tfenv verify the integrity of downloaded Terraform binaries?

Tfenv automatically downloads the SHA256SUMS file published by HashiCorp alongside the Terraform release. It verifies the checksum of the downloaded zip file against this list to ensure the binary has not been corrupted during download.

Can the Tfenv version manager work in an air-gapped environment?

Yes. You can point the TFENV_REMOTE environment variable to an internal HTTP server or artifact repository (like Artifactory or Nexus) hosting the Terraform binaries and checksums.

How do I configure Tfenv to use an internal mirror for Terraform downloads?

Export the TFENV_REMOTE environment variable with the base URL of your internal mirror (e.g., export TFENV_REMOTE='https://internal-mirror.corp.com/tf'). Tfenv will append the specific version paths to this base URL.

Does Tfenv check GPG signatures for HashiCorp Terraform releases?

By default, Tfenv performs SHA256 verification. For strict enterprise GPG signature verification, you can provide your own HashiCorp GPG public key by configuring the TFENV_GPG_KEYRING environment variable.

Is it safe to use Tfenv in highly regulated enterprise DevOps environments?

Yes. Tfenv does not phone home, collect telemetry, or require external runtimes. It simply wraps HashiCorp's official binaries in a localized user directory, making it compliant with strict enterprise security policies.

Why is Tfenv not switching my active Terraform CLI version correctly?

This usually happens if your shell PATH is pointing to a system-installed Terraform rather than Tfenv's shim. Ensure ~/.tfenv/bin is prepended to your PATH at the very beginning of your shell configuration file.

How do I uninstall a specific Terraform version using the version manager?

To uninstall a version, run tfenv uninstall <version>. Tfenv will refuse to uninstall the currently active version unless you pass the --force flag, which prevents accidental removal during an active deployment.

What should I do if Tfenv fails to download a Terraform version behind a proxy?

If you are behind a corporate proxy, set the standard HTTPS_PROXY and HTTP_PROXY environment variables. If the proxy uses a custom CA certificate, point TFENV_CURL_OPTIONS to the certificate bundle.

How can I update the Tfenv version manager to the latest release?

If you installed via direct download, simply download the latest archive and replace the existing files. If you used Homebrew, run brew upgrade tfenv. This ensures you have the latest features and support for new Terraform releases.

Where are Tfenv and Terraform versions stored on my system?

By default, the Tfenv script is stored in ~/.tfenv. The downloaded Terraform binaries are stored in ~/.tfenv/versions/<version>, and the active shim is symlinked in ~/.tfenv/bin. You can change this using the TFENV_ROOT variable.

Honest Assessment

Advantages and Limitations of Tfenv

We love Tfenv, but no tool is perfect for every scenario. Here's an honest look at where it shines and where it might fall short for Infrastructure as Code teams.

Tfenv Advantages for DevOps Teams

  • Zero DependenciesNo Node.js, Python, or Ruby runtimes required. Just a POSIX shell and curl.
  • Project-Level PinningPrevents version drift effortlessly across team members and CI runners.
  • Security FirstGPG signature verification ensures downloaded binaries haven't been tampered with.
  • Air-Gapped SupportWorks in restricted environments via internal mirrors without public internet access.
  • Blazing FastInstalls cached versions in milliseconds, saving precious CI pipeline minutes.

Tfenv Limitations & Considerations

  • Terraform OnlyUnlike polyglot version managers, Tfenv doesn't manage other tools like Node or AWS CLI.
  • Shell-Script BasedSlightly slower execution than compiled Go binaries, though unnoticeable in practice.
  • No GUIStrictly CLI-driven, which might deter beginners who prefer graphical interfaces.
  • Windows SetupRequires manual PATH configuration on native Windows, though WSL2 works perfectly.
  • Learning CurveRequires basic shell scripting knowledge to troubleshoot edge cases effectively.
Community Voices

Industry Testimonials & DevOps Reviews

Don't just take our word for it. Here's what engineering teams have to say after switching to Tfenv for their Infrastructure as Code version management.

Tfenv eliminated our "works on my machine" CI failures. The fact that it reads .terraform-version automatically on cd is pure magic. Onboarding new engineers dropped from half a day to ten minutes.
SJ
Sarah JenkinsLead DevOps Engineer, FinTech Corp
I manage 30+ microservices with different Terraform versions. Tfenv made this trivial. The GPG verification is a massive bonus for our compliance team. It just works, silently, every single time.
MC
Marcus ChenPlatform Architect, CloudScale
The air-gapped support alone is worth it. In our regulated environment, we can't use unverified binaries. Tfenv lets us point to our internal mirror and verify with our own GPG keys. It's exactly what we needed.
EP
Elena PetrovaSRE Lead, SecureGov Solutions
Scroll to Top