antonbabenko / pre-commit-terraform

pre-commit git hooks to take care of Terraform configurations 🇺🇦
MIT License
3.16k stars 535 forks source link

terraform_docs hook reporting error when using --recursive-path #439

Closed leandrogattas closed 1 year ago

leandrogattas commented 1 year ago

Context

  1. Terraform modules structure: ./modules/aws/amp ./modules/aws/ecr

  2. pre-commit-config.yaml (just relevant part)

When running precommit (e.g. pre-commit run --all-files) it reports an error as the intermediate folder is not existing (or similar)

Terraform docs...........................................................Failed
- hook id: terraform_docs

**Error: stat modules/aws: no such file or directory**

That folder is containing no file, but only the two folders for the ecr and amp modules.

This error should not appear (if I understand correctly how it should work).

Environment information

$ uname -a
Darwin PMIPLKRAL87212 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101 arm64
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin21)
pre-commit 2.20.0
Terraform v1.2.6
python SKIPPED
Python 3.10.6
checkov 2.1.270
terraform-docs version v0.16.0 darwin/arm64
terragrunt version v0.38.12
terrascan terrascan SKIPPED
TFLint version 0.40.0
+ ruleset.terraform (0.1.0-bundled)
tfsec v1.27.6
tfupdate tfupdate SKIPPED
hcledit hcledit SKIPPED
file content ```bash repos: - repo: https://github.com/antonbabenko/pre-commit-terraform # Source: https://github.com/antonbabenko/pre-commit-terraform#terraform_docs rev: v1.76.0 hooks: - id: terraform_fmt - id: terraform_docs args: - '--args=--recursive' - '--args=--output-file=README.md' - '--args=--recursive-path=/modules/' - id: terraform_validate - id: terraform_checkov ```
MaxymVlasov commented 1 year ago

https://github.com/antonbabenko/pre-commit-terraform#terraform_docs, step 4.