• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Manage terragrunt versions - the tgswitch command line tool lets you switch between different versions of terragrunt

Build Status Go Report Card CircleCI

Terragrunt Switcher

drawing

The tgswitch command line tool lets you switch between different versions of terragrunt. If you do not have a particular version of terragrunt installed, tgswitch will download the version you desire. The installation is minimal and easy. Once installed, simply select the version you require from the dropdown and start using terragrunt.

Installation

tgswitch is available for MacOS and Linux based operating systems.

Homebrew

Installation for MacOS is the easiest with Homebrew. If you do not have homebrew installed, click here.

brew install warrensbox/tap/tgswitch

Linux

Installation for Linux operation systems.

curl -L https://raw.githubusercontent.com/warrensbox/tgswitch/release/install.sh | bash

Install from source

Alternatively, you can install the binary from the source here.

Having trouble installing.

How to use:

Use dropdown menu to select version

drawing

  1. You can switch between different versions of terragrunt by typing the command tgswitch on your terminal.
  2. Select the version of terragrunt you require by using the up and down arrow.
  3. Hit Enter to select the desired version.

The most recently selected versions are presented at the top of the dropdown.

Supply version on command line

drawing

  1. You can also supply the desired version as an argument on the command line.
  2. For example, tgswitch 0.37.1 for version 0.37.1 of terragrunt.
  3. Hit Enter to switch.

Use environment variables

drawing

  1. You can also set the TG_VERSION environment variable to your desired terragrunt version. For example:
export TG_VERSION=0.37.0
tgswitch #will automatically switch to terragrunt version 0.37.0

Use .tgswitch.toml file (For non-admin AND Apple M1 users with limited privilege on their computers)

Specify a custom binary path for your terragrunt installation

drawing

drawing

  1. Create a custom binary path. Ex: mkdir /Users/uveerum/bin (replace uveerum with your username)
  2. Add the path to your PATH. Ex: export PATH=$PATH:/Users/uveerum/bin (add this to your bash profile or zsh profile)
  3. Pass -b or --bin parameter with your custom path to install terragrunt. Ex: tgswitch -b /Users/uveerum/bin/terragrunt 0.34.0
  4. Optionally, you can create a .tgswitch.toml file in your terragrunt directory(current directory) OR in your home directory(~/.tgswitch.toml). The toml file in the current directory has a higher precedence than toml file in the home directory
  5. Your .tgswitch.toml file should look like this:
bin = "/usr/local/bin/terragrunt"
version = "0.34.0"
  1. Run tgswitch and it should automatically install the required terragrunt version in the specified binary path

NOTE

  1. For linux users that do not have write permission to /usr/local/bin/, tgswitch will attempt to install terragrunt at $HOME/bin. Run export PATH=$PATH:$HOME/bin to append bin to PATH
  2. For windows host, tgswitch need to be run under Administrator mode, and $HOME/.tgswitch.toml with bin must be defined (with a valid path) as minimum, below is an example for $HOME/.tgswitch.toml on windows
bin = "C:\\Users\\<%USRNAME%>\\bin\\terragrunt.exe"

Use .tgswitchrc file

drawing

  1. Create a .tgswitchrc file containing the desired version
  2. For example, echo "0.33.0" >> .tgswitchrc for version 0.33.0 of terragrunt
  3. Run the command tgswitch in the same directory as your .tgswitchrc

Instead of a .tgswitchrc file, a .terragrunt-version file may be used as well

Use terragrunt.hcl file

drawing

If a terragrunt.hcl file with the terragrunt constrain is included in the current directory, it should automatically download or switch to that terragrunt version. For example, the following should automatically switch terragrunt to version 0.36.0:

terragrunt_version_constraint = ">= 0.36, < 0.36.1"
...

Get the version from a subdirectory

tgswitch --chdir terragrunt_dir
tgswitch -c terragrunt_dir

Automatically switch with bash

Add the following to the end of your ~/.bashrc file: (Use either .tgswitchrc or .tgswitch.toml or .terragrunt-version)

cdtgswitch(){
  builtin cd "$@";
  cdir=$PWD;
  if [ -e "$cdir/.tgswitchrc" ]; then
    tgswitch
  fi
}
alias cd='cdtgswitch'

Automatically switch with zsh

Add the following to the end of your ~/.zshrc file:

load-tgswitch() {
  local tgswitchrc_path=".tgswitchrc"

  if [ -f "$tgswitchrc_path" ]; then
    tgswitch
  fi
}
add-zsh-hook chpwd load-tgswitch
load-tgswitch

NOTE: if you see an error like this: command not found: add-zsh-hook, then you might be on an older version of zsh (see below), or you simply need to load add-zsh-hook by adding this to your .zshrc:

autoload -U add-zsh-hook

older version of zsh

cd(){
  builtin cd "$@";
  cdir=$PWD;
  if [ -e "$cdir/.tgswitchrc" ]; then
    tgswitch
  fi
}

Issues

Please open issues here: New Issue

Upcoming Features

N/A

More Repositories

1

terraform-switcher

A command line tool to switch between different versions of terraform (install with homebrew and more)
Go
1,344
star
2

hubapp

The `hubapp` command line tool lets you install app binaries from github user's releases.
Go
27
star
3

aws-find

Lookup AWS instances' IP address and ID by their AWS tag name
Shell
7
star
4

bulk-emailer

Send bulk emails from csv file using AWS SES
Shell
4
star
5

homebrew-tap

warrensbox uses homebrew taps - taps are external sources of Homebrew formulae and/or external commands
Ruby
4
star
6

s3upload

Upload multiple files to S3 concurrently with or without a config file. WIP - do not use yet
Go
3
star
7

jscheck

The jscheck command line tool looks for json files and check's its validity. Sometimes not all our json files end with a .json extension. jscheck tries to figure out if your file has is a json format before linting.
Shell
3
star
8

falcon-form

Simply send your contact form to our URL and we'll forward the information to your email
Go
3
star
9

medium-to-html

How to include your medium posts on your html website
JavaScript
2
star
10

terragunt-versions-list

This repo should be updated every 12 hours. It should simply get the list of terragrunt versions.
Go
2
star
11

health-check

The `health-check` command-line tool concurrently checks all target groups' health status.
Go
2
star
12

covid-vaccine-tracker

A lightweight application (lambda function) that notifies you when a vaccine appointment becomes available near you.
Go
2
star
13

go-rb-py-aws

Ubuntu container with Go 1.10 + Ruby 2.4 + Python 3 + AWS cli
Dockerfile
1
star