Unified, minimal terraform and terragrunt version manager.
- Minimal by design: no shims, no magic, quiet, but extendable thru scripting
- SHA256 checksums are checked for terraform and terragrunt binary downloads
- PGP signatures are checked for terraform binary downloads (if Hashicorp's public key is configured)
- Linux (amd64, arm64)
- NOTE: only terraform
0.11.15
,0.12.{30,31}
,0.13.5+
and terragrunt0.28.12+
ship linux arm64 binaries
- NOTE: only terraform
- macOS (amd64, arm64)
- NOTE: only terraform
1.1.0+
and terragrunt0.28.12+
ship macOS arm64 binaries
- NOTE: only terraform
- Windows (amd64)
- Download terve for your platform, check file integrity, and install the binary somewhere in your
PATH
, e.g./usr/local/bin/terve
-
On Linux/macOS, file integrity can be checked in the directory where you downloaded the binary and
SHA256SUMS
, like so:$ ls SHA256SUMS terve_linux_amd64 $ sha256sum -c --ignore-missing 2>/dev/null SHA256SUMS terve_linux_amd64: OK
-
On Linux/macOS, be sure to make the binary executable:
chmod +x terve
-
- Create the
~/.terve
directory tree by runningterve --bootstrap
- Add the
~/.terve/bin
directory toPATH
(using e.g..bashrc
or Windows' control panel) - Copy Hashicorp's PGP public key in
~/.terve/etc/terraform.asc
(read-only, mode0444
on Linux/macOS)- This public key is used to verify terraform binary download PGP signatures
- If not installed (or bad file permissions), terve will log a warning for terraform installs
- Install your desired versions of terraform and terragrunt
- Select your desired versions of terraform and terragrunt
Terve uses hard links to configure selected terraform/terragrunt binary versions.
All files are kept in directory ~/.terve
like so (example directory tree for Linux):
/home/whoami/.terve
├── bin
│ ├── terraform
│ └── terragrunt
├── etc
│ └── terraform.asc
├── opt
│ ├── terraform
│ │ ├── 0.1.0
│ │ ├── 1.0.2
│ │ └── 1.0.3
│ └── terragrunt
│ ├── 0.0.4
│ ├── 0.1.0
│ └── 0.31.2
└── var
├── terraform
│ └── version
└── terragrunt
└── version
bin
– selected terraform and terragrunt binaries (hard-linked to files inopt
)etc
– configurationopt
– installed terraform and terragrunt binaries, version is encoded in file namevar
– variable data, currently only holders for selected version strings
Managed <binary>
is tf
(long form: terraform
) or tg
(long form: terragrunt
).
Install, select and remove are idempotent, and can be run multiple times for a version without error.
Lists installed or available (remote) versions, sorted latest first.
Syntax: terve l[ist] <binary> [spec]
where spec
is r[emote]
terve l tf
lists installed (local) terraform versionsterve l tf r
lists available (remote) terraform versionsterve l tf r | tac
lists available terraform versions, sorted oldest firstterve l tg r | grep 0.29.
lists available terragrunt 0.29.x versions
💡 List remote does not return pre-release versions (e.g. terraform 0.15.0-rc2
), but such versions can be installed/selected/removed (for testing).
Installs a specific version.
Syntax: terve i[nstall] <binary> <semver>
terve i tf 0.12.31
installs terraform version 0.12.31terve i tf "$(terve l tf r | head -n1)"
installs latest version of terraformterve i tf "$(cat .terraform-version)"
installs terraform version defined in.terraform-version
terve i tg "$(cat .terragrunt-version)"
installs terragrunt version defined in.terragrunt-version
terve l tg r | grep 0.29. | xargs -n1 -P4 terve i tg
installs all available terragrunt 0.29.x versions
0.18.1
do not ship SHA256SUMS
files, so their file integrity cannot be checked
Selects an installed version for use.
Syntax: terve s[elect] <binary> <semver>
terve s tf 0.12.31
selects terraform version 0.12.31terve s tf "$(cat .terraform-version)"
selects terraform version defined in.terraform-version
Removes an installed version.
Syntax: terve r[emove] <binary> <semver>
terve r tf 0.12.31
removes terraform version 0.12.31terve l tf | grep 0.11. | xargs -n1 terve r tf
removes all installed terraform 0.11.x versions
💡 Removing a version does not reset current selection
Tells which version is currently selected.
Syntax: terve w[hich] <binary>
$ terve w tf
0.15.5
Simple switch to specified terraform version.
function tfv {
local version="$1"
if [ -z "$version" ]; then
echo "Usage: tfv <version>, e.g. tfv 1.2.3"
return 1
fi
terve i tf "$version" >/dev/null && \
terve s tf "$version" >/dev/null && \
echo "Switched to terraform $version"
}
Use terraform and terragrunt versions defined in .terraform-version
and .terragrunt-version
(in current working directory or any parent directory)
#!/bin/sh
upcat() {
file="$1"
while [ "$PWD" != "/" ]; do
if [ -r "$file" ]; then
cat "$file"
break
fi
cd ..
done
}
tf_version="$(upcat .terraform-version)"
tg_version="$(upcat .terragrunt-version)"
if [ -z "$tf_version" ]; then
echo "ERROR: No .terraform-version file found"
exit 1
fi
if [ -z "$tg_version" ]; then
echo "ERROR: No .terragrunt-version file found"
exit 2
fi
terve i tf "$tf_version" && terve s tf "$tf_version"
terve i tg "$tg_version" && terve s tg "$tg_version"
You need cargo (Rust's build tool). To run all tests, run cargo test
.
Visual Studio Code with rust-analyzer provides a good IDE experience.
To build a release binary, run cargo build --release
. Binary is then found in target/release/
.