-
-
Save ibrahima/1a4c0a3369e590715988f1390b4effdd to your computer and use it in GitHub Desktop.
A Terraform validation and formatting pre-commit hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# Formats any *.tf files according to the hashicorp convention | |
files=$(git diff --cached --name-only --diff-filter=d) | |
for f in $files | |
do | |
if [ -e "$f" ] && [[ $f == *.tf ]]; then | |
terraform fmt -check=true $f | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment