Skip to content

Commit

Permalink
Merge pull request #24 from mineiros-io/soerenmartius/terraform-v0.15…
Browse files Browse the repository at this point in the history
…-compatibility

fix: ensure Terraform v0.15 compatibility for terraform validate
  • Loading branch information
soerenmartius authored May 6, 2021
2 parents 5566c86 + 526f996 commit d1d7965
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pre_commit_hooks/terraform/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ set -e
# set default aws region for validating aws providers
export AWS_REGION=${AWS_REGION:="none"}

TF_VALIDATE_ERROR=0

while read -r dir; do
terraform init -backend=false "$dir"
terraform validate "$dir"
done < <(printf '%s\n' "${@}" | xargs -i dirname {} | sort -u)
echo "### Running 'terraform validate' in directory '$dir'"

pushd "$dir" >/dev/null
terraform init -backend=false || TF_VALIDATE_ERROR=$?
terraform validate || TF_VALIDATE_ERROR=$?
popd >/dev/null
done < <(printf '%s\n' "${@}" | xargs -n1 dirname | sort -u | uniq)

exit ${TF_VALIDATE_ERROR}

0 comments on commit d1d7965

Please sign in to comment.