antonbabenko / pre-commit-terraform

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

terraform_tflint.sh broken without pushd #304

Closed grimm26 closed 2 years ago

grimm26 commented 2 years ago

Describe the bug

tflint fails with errors about modules not being loaded like:

Error: `foo` module is not found. Did you run `terraform init`?

because it runs from the top directory of the repo Commit 7c6ad7c refactored terraform_tflint.sh and part of that changed the execution of tflint to use the target directory, $path_uniq, as an argument to tflint instead of using pushd to change the working directory for the execution of tflint.

How can we reproduce it?

Have a directory structure in your repository taht has the .prec-commit-config.yaml at the top and one or more subdirectories with terraform files in them that use modules.

Environment information

INSERT_OUTPUT_HERE
 ❯ tflint --version
TFLint version 0.34.0
+ ruleset.aws (0.10.0-bundled)
file content ```bash repos: - repo: https://github.com/antonbabenko/pre-commit-terraform rev: v1.62.0 hooks: - id: terraform_fmt - id: terragrunt_fmt - id: terraform_tflint - repo: local hooks: - id: autoupdate name: pre-commit autoupdate language: system exclude: '.*' always_run: true entry: pre-commit args: [autoupdate] ```
yermulnik commented 2 years ago

Already being worked on in https://github.com/antonbabenko/pre-commit-terraform/pull/302