Skip to content
Snippets Groups Projects
Commit d2681a69 authored by nimrod's avatar nimrod
Browse files

Validate Terraform according to workspace.

Use the variable file matching the workspace when validating. Also when
validating and formatting, show the diff.
parent 55d07e9e
Branches
No related tags found
No related merge requests found
...@@ -123,7 +123,7 @@ alias listen_tcp='nc -vlk 0.0.0.0' ...@@ -123,7 +123,7 @@ alias listen_tcp='nc -vlk 0.0.0.0'
alias listen_udp='nc -uvlk 0.0.0.0' alias listen_udp='nc -uvlk 0.0.0.0'
alias listen_unix='nc -Uvlk' alias listen_unix='nc -Uvlk'
alias tfa='terraform apply tfplan' alias tfa='terraform apply tfplan'
alias tfvf='terraform validate && terraform fmt' alias tfvf='tfv && terraform fmt -diff'
if ! command -v notify-send > /dev/null if ! command -v notify-send > /dev/null
then then
...@@ -174,6 +174,16 @@ tfi () { ...@@ -174,6 +174,16 @@ tfi () {
fi fi
} }
tfv () {
workspace="$(terraform workspace show)"
if [ "$workspace" = "default" ] || [ ! -f "$workspace.tfvars" ]
then
terraform validate "$@"
else
terraform validate -var-file "$workspace.tfvars" "$@"
fi
}
genpass () { genpass () {
bytes="${1:-32}" bytes="${1:-32}"
head --bytes="$bytes" /dev/urandom | base64 --wrap=0 head --bytes="$bytes" /dev/urandom | base64 --wrap=0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment