Python base simple terraform pre-commit hook.
Requires python version 3.9 or above.
Add the following repo to your .pre-commit-config.yaml
...
- repo: https://github.com/devopsforhumans/tf-pre-commit
rev: v1.0.4
hooks:
- id: terraform-fmt
...if you want to provide options or global options (try terraform fmt --help) then use args
...
- repo: https://github.com/devopsforhumans/tf-pre-commit.git
rev: v1.0.4
hooks:
- id: terraform-fmt
args:
- --options="-no-color -diff -check"
...Note If
-recursiveis provided in the--optionsargument, terraform formatting will recursively format the parent directory of the file in context.
-
Create virtual environment
python3 -m venv .venv
-
Activate virtual environment
source .venv/bin/activateor for windows
.\.venv\Scripts\activate.ps1
-
Install dependencies
To install dependencies with
pipenvuse the following commandpython3 -m pip install -r requirements.txt
To install
devdependencies use--devflagpython3 -m pip install -r requirements_dev.txt
tf-pre-commit is distributed under the terms of the BSD-3-Clause license.