Skip to content

Commit

Permalink
Merge pull request #5 from mineiros-io/mariux/fix-terraform-aws-modul…
Browse files Browse the repository at this point in the history
…e-validation

fix terraform aws module validation
  • Loading branch information
mariux authored Jan 20, 2020
2 parents 7e23ec1 + 25f902d commit 7184129
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
9 changes: 3 additions & 6 deletions pre_commit_hooks/terraform/fmt.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/bin/bash
set -e

# set -e is considered to be a bad practice as written here http://mywiki.wooledge.org/BashFAQ/105
# so we use a trap instead
trap 'exit' ERR

# Make environment variables working in OSX GUI apps such as Github Desktop https://stackoverflow.com/q/135688/483528
# Make environment variables working in OSX GUI apps such as Github Desktop
# https://stackoverflow.com/q/135688/483528
export PATH=$PATH:/usr/local/bin

terraform fmt -recursive

8 changes: 3 additions & 5 deletions pre_commit_hooks/terraform/tflint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/bin/bash
set -e

# set -e is considered to be a bad practice as written here http://mywiki.wooledge.org/BashFAQ/105
# so we use a trap instead
trap 'exit' ERR

# Make environment variables working in OSX GUI apps such as Github Desktop https://stackoverflow.com/q/135688/483528
# Make environment variables working in OSX GUI apps such as Github Desktop
# https://stackoverflow.com/q/135688/483528
export PATH=$PATH:/usr/local/bin

for file in "$@"; do
Expand Down
12 changes: 5 additions & 7 deletions pre_commit_hooks/terraform/validate.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/bin/bash
set -e

# set -e is considered to be a bad practice as written here http://mywiki.wooledge.org/BashFAQ/105
# so we use a trap instead
trap 'exit' ERR

# Make environment variables working in OSX GUI apps such as Github Desktop https://stackoverflow.com/q/135688/483528
# Make environment variables working in OSX GUI apps such as Github Desktop
# https://stackoverflow.com/q/135688/483528
export PATH=$PATH:/usr/local/bin

# set default aws region for validating aws providers
export AWS_REGION=${AWS_REGION:="none"}

for dir in $(echo "$@" | xargs -n1 dirname | sort -u | uniq); do
while read dir; do
terraform init -backend=false "$dir"
terraform validate "$dir"
done
done < <(printf '%s\n' "${@%/*}" | sort -u)

0 comments on commit 7184129

Please sign in to comment.