joerx / tfm

Simple shell script to manage multiple Terraform versions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform Version Manager

Lightweight bash script to manage and quickly switch terraform versions

Requirements

Currently tested on macOS x64 and arm64. May test on Linux when I get to it, contributions welcome. This is a bash script, no native Windows support is planned - If you get this to work on WSL2, let me know ;)

Setup

# ~/.bash_profile
export PATH=$HOME/.local/bin:$PATH

# or:

export PATH=$HOME/.bin:$PATH
export TFM_PREFIX=$HOME/.bin

Usage

Usage:

$ tfm
Usage: tfm <subcommand> [args]
...

List versions:

Versions:
* 1.0.11
  1.1.7

Aliases:
  terraform = 1.0.11
  tf10 = 1.0.11
  tf11 = 1.1.7

Switch default version:

$ tfm use 1.1.7
Aliased terraform version 1.1.7 to terraform
Current terraform version is 1.1.7

$ terraform version
Terraform v1.1.7

Set an alias:

$ tfm alias 1.1.7 tf11
Aliased terraform version 1.1.7 to tf11

Install:

$ tfm install 1.1.7
...

List installation candidates:

$ tfm releases | grep ^1.1

Customization

By default, terraform versions are installed in ~/.tfm and the terraform binary will be linked to ~/.local/bin.

Some env vars can be used to customize those defaults. Run tfm printenv to see which ones exist and what the current values are:

$ tfm printenv
Architecture:
  darwin_arm64
Environment:
  TFM_PREFIX: /Users/joerg.henning/.local/bin
  TFM_DIR: /Users/joerg.henning/.tfm

Acknowledgements

Thanks to Hashicorp for Terraform and nvm for inspiration.

About

Simple shell script to manage multiple Terraform versions

License:Apache License 2.0


Languages

Language:Shell 100.0%