tfswitch · the right Terraform version, automatically

4 months ago

Every Terraform project pins its own version. Run the wrong one, and Terraform stops with a version error before it does anything. tfswitch downloads and switches to the right version on demand.

Ask about this presentation

Chapters

  1. 0:00tfswitch
  2. 0:11One command line tool
  3. 0:24Install it
  4. 0:31The first win: a version dropdown
  5. 0:43Or pin one on the command line
  6. 0:57The payoff: it reads your project
  7. 1:11The right version, automatically
Show transcript
  1. Every Terraform project pins its own version. Run the wrong one, and Terraform stops with a version error before it does anything. tfswitch downloads and switches to the right version on demand.

    Slide text
    tfswitch logo

    Install and switch Terraform and OpenTofu versions on demand.

    run tfswitch → pick a version → it is your active terraform
  2. tfswitch is one small command line tool. It downloads and switches between versions on demand, then makes your choice the active terraform binary. The same workflow covers both Terraform and OpenTofu, so you never hand manage binaries again.

    Slide text

    It downloads and switches between released versions, then makes your choice the active binary.

    Terraform + OpenTofu → one tfswitch workflow
  3. Install it with Homebrew, on macOS or Linux. Or on any Linux box, pipe the install script. Either way, you get a single binary with no dependencies.

    Slide text
    # macOS or Linux, with Homebrew
    brew install warrensbox/tap/tfswitch
    # or on any Linux box, run the install script
    curl -L https://raw.githubusercontent.com/warrensbox/\
    terraform-switcher/master/install.sh | bash

    One binary, no dependencies.

  4. Now the first win. Just run tfswitch. It shows every released version in a dropdown. Arrow to the one you want, press Enter, and it downloads and switches to it. Your most recent picks float to the top.

    Slide text
    Running tfswitch opens an interactive version dropdown

    Arrow through every released version · press Enter to download and switch.

  5. Already know the version you need? Pass it as an argument. tfswitch 1.7.0 grabs exactly that. Or ask for the latest stable release. Add the list all flag to see every version, including beta, alpha, and release candidate builds.

    Slide text
    tfswitch 1.7.0       # switch to exactly 1.7.0
    tfswitch --latest    # newest stable release

    tfswitch --list-all lists every version, including beta, alpha, and rc builds.

  6. Here is the real payoff. Drop a version file in your project, or add a required version to your Terraform. Then just run tfswitch with no arguments. It reads the constraint and installs the matching version. Change into any repository, and the correct version is active, every time.

    Slide text
    terraform {
      required_version = ">= 0.12.9"
    }
    tfswitch auto-detecting the required version from a project file

    Precedence: config files › module required_version › TF_VERSION › command-line argument.

  7. That is the whole idea. Pick from a dropdown, pin one on the command line, or let tfswitch read your project and switch automatically. It handles Terraform and OpenTofu the same way. Install it, and start from the docs.

    Slide text
    • Dropdown · pick any released version interactively.
    • Pin · pass an exact version on the command line.
    • Auto-detect · reads your project's required version.
    • Terraform + OpenTofu · the same workflow for both.

    brew install warrensbox/tap/tfswitch  ·  tfswitch.warrensbox.com

What happened in AI today, in your inbox

One short email each evening. Read it and you’re caught up.

Built with ❤️ in New York