diff --git a/.bashrc b/.bashrc index 31675f19ce5fa3c092470fdbb7bfaffe5cb8d71a..56fc58a8c61d15f880238ac469c9c937c5f10022 100644 --- a/.bashrc +++ b/.bashrc @@ -123,7 +123,7 @@ alias listen_tcp='nc -vlk 0.0.0.0' alias listen_udp='nc -uvlk 0.0.0.0' alias listen_unix='nc -Uvlk' alias tfa='terraform apply tfplan' -alias tfvf='terraform validate && terraform fmt' +alias tfvf='tfv && terraform fmt -diff' if ! command -v notify-send > /dev/null then @@ -174,6 +174,16 @@ tfi () { fi } +tfv () { + workspace="$(terraform workspace show)" + if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ] + then + terraform validate "$@" + else + terraform validate -var-file "$workspace.tfvars" "$@" + fi +} + genpass () { bytes="${1:-32}" head --bytes="$bytes" /dev/urandom | base64 --wrap=0