Skip to content

Instantly share code, notes, and snippets.

@sortega
Last active March 31, 2020 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sortega/6c99aac8b04a636032340e50c465e177 to your computer and use it in GitHub Desktop.
Save sortega/6c99aac8b04a636032340e50c465e177 to your computer and use it in GitHub Desktop.
Place this in .git/hooks to avoid commiting malformed terraform sources
#!/bin/bash
set -e
MODULES=`find . -name '*.tf' -print0 | xargs -0 -n1 dirname | sort --unique | grep -v .terraform`
echo -n "fmt check"
for MODULE in $MODULES; do
(terraform fmt -check && echo -n ".") &
done
wait
echo " OK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment