pre-commit hooks to keep Terraform configurations in a good shape ;)
fmt
- Rewrites all Terraform configuration files to a canonical format.validate
- Validates all Terraform configuration files.
Enjoy the clean and documented code!
Follow the steps below to get started
install the pre-commit package
- Using pip:
pip install pre-commit
- Using homebrew:
brew install pre-commit
Step into the repository you want to have the pre-commit hooks installed and run:
cat <<EOF > .pre-commit-config.yaml
- repo: git://github.com/anmolnagpal/git-hooks-terraform
rev: v1.0.0 # Use the ref you want to point at
hooks:
- id: fmt
- id: validate
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0 # Use the ref you want to point at
hooks:
- id: check-merge-conflict
EOF
Install the pre-commit hook
pre-commit install
After pre-commit hook has been installed you can run it manually on all files in the repository
pre-commit run -a