You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[`checkov`][checkov repo] required for `terraform_checkov` hook
232
+
*[`terraform-docs`][terraform-docs repo] 0.12.0+ required for `terraform_docs` hook
233
+
*[`terragrunt`][terragrunt repo] required for `terragrunt_validate` and `terragrunt_valid_inputs` hooks
234
+
*[`terrascan`][terrascan repo] required for `terrascan` hook
235
+
*[`TFLint`][tflint repo] required for `terraform_tflint` hook
236
+
*[`TFSec`][tfsec repo] required for `terraform_tfsec` hook
237
+
*[`Trivy`][trivy repo] required for `terraform_trivy` hook
238
+
*[`infracost`][infracost repo] required for `infracost_breakdown` hook
239
+
*[`jq`][jq repo] required for `terraform_validate` with `--retry-once-with-cleanup` flag, and for `infracost_breakdown` hook
240
+
*[`tfupdate`][tfupdate repo] required for `tfupdate` hook
241
+
*[`graphviz`](https://www.graphviz.org/download) required for `terraform_graph` hook.
242
+
*[`hcledit`][hcledit repo] required for `terraform_wrapper_module_for_each` hook
243
+
244
+
245
+
#### 1.1 Custom Terraform binaries and OpenTofu support
246
+
247
+
It is possible to set custom path to `terraform` binary.
248
+
This makes it possible to use [OpenTofu](https://opentofu.org) binary (`tofu`) instead of `terraform`.
249
+
250
+
How binary discovery works and how you can redefine it (first matched takes precedence):
251
+
252
+
1. Check if per hook configuration `--hook-config=--tf-path=<path_to_binary_or_binary_name>` is set
253
+
2. Check if `PCT_TFPATH=<path_to_binary_or_binary_name>` environment variable is set
254
+
3. Check if `TERRAGRUNT_TFPATH=<path_to_binary_or_binary_name>` environment variable is set
255
+
4. Check if `terraform` binary can be found in the user's `$PATH`
256
+
5. Check if `tofu` binary can be found in the user's `$PATH`
257
+
258
+
253
259
### 2. Install the pre-commit hook globally
254
260
255
261
> [!NOTE]
@@ -277,6 +283,14 @@ repos:
277
283
EOF
278
284
```
279
285
286
+
If this repository was initialized locally via `git init` or `git clone`_before_
287
+
you installed the pre-commit hook globally ([step 2](#2-install-the-pre-commit-hook-globally)),
288
+
you will need to run:
289
+
290
+
```bash
291
+
pre-commit install
292
+
```
293
+
280
294
### 4. Run
281
295
282
296
Execute this command to run `pre-commit` on all files in the repository (not only changed files):
@@ -352,10 +366,10 @@ Config example:
352
366
- id: terraform_tflint
353
367
args:
354
368
- --args=--config=${CONFIG_NAME}.${CONFIG_EXT}
355
-
- --args=--module
369
+
- --args=--call-module-type="all"
356
370
```
357
371
358
-
If for config above set up `export CONFIG_NAME=.tflint; export CONFIG_EXT=hcl` before `pre-commit run`, args will be expanded to `--config=.tflint.hcl --module`.
372
+
If for config above set up `export CONFIG_NAME=.tflint; export CONFIG_EXT=hcl` before `pre-commit run`, args will be expanded to `--config=.tflint.hcl --call-module-type="all"`.
359
373
360
374
### All hooks: Set env vars inside hook at runtime
0 commit comments