Skip to content

Instantly share code, notes, and snippets.

@medwig
Created December 11, 2019 15:44
Show Gist options
  • Save medwig/d7fb499eb84964523c871a560438c6b9 to your computer and use it in GitHub Desktop.
Save medwig/d7fb499eb84964523c871a560438c6b9 to your computer and use it in GitHub Desktop.
Terraform echo workspace before running apply or output command
# Run tf with echo tf-workspace
tf_with_tf_workspace() {
if [[ "$@" == "apply" ]] || [[ "$@" == "output" ]];
then
\terraform workspace list;
fi
\terraform "$@";
}
alias tf="terraform"
alias terraform="tf_with_tf_workspace"
@medwig
Copy link
Author

medwig commented Dec 11, 2019

Add these lines to ~/.bashrc (or ~/.zshrc). It also creates the shorter tf alias to run terraform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment