We strongly urge that all code be linted prior to checking into to git. Running
terraform fmt on the codebase before committing will accomplish this.
To set this up so that it happens automatically prior to any commit, configure
git pre-commit hooks using the
brew install pre-commit
pre-commit install in a given terraform repo to configure the hooks.
repogit //github.com/antonbabenko/pre-commit-terraform shav1.5.0 hooks idterraform_fmt idterraform_validate_no_variables
After setting this up, every time you commit, the
terraform fmt command will be run to canonicalize your files and a basic smoke test to validate all configurations without requiring required variables to be set.
Any time your commit affects any
*.tf files, the validator will ensure well-formed terraform code.