Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need terraform_tflint option to not find more paths to run in. #300

Closed
grimm26 opened this issue Dec 13, 2021 · 5 comments
Closed

Need terraform_tflint option to not find more paths to run in. #300

grimm26 opened this issue Dec 13, 2021 · 5 comments

Comments

@grimm26
Copy link

grimm26 commented Dec 13, 2021

I need a way for terraform_tflint to not descend into subdirectories. I only want it to check the current directory.

Use case

I am using this with terraform module repositories. The module has a test/ directory that has a test invocation of the module that people can use to verify that their changes will plan out fine. This causes an error when running the pre-commit check.

Terraform validate with tflint...........................................Failed
- hook id: terraform_tflint
- exit code: 1


TFLint in test/:
Failed to load configurations. 1 error(s) occurred:

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

  on test/test.tf line 27, in module "test":
  27: module "test" {

I ran a terraform init in both direcotories, but I think since tflint is being run from ./ it doesn't see that the module is loaded in ./test.

How could pre-commit-terraform help solve your problem?

Add an option to disable searching for paths to run the tflint check in. Just run it in ./

@grimm26 grimm26 added the feature New feature or request label Dec 13, 2021
@grimm26
Copy link
Author

grimm26 commented Dec 13, 2021

#125 changed the functionality, causing the breakage. No mention of this change in the PR, only a minor version tick.

@yermulnik
Copy link
Collaborator

yermulnik commented Dec 13, 2021

Add an option to disable searching for paths to run the tflint check in. Just run it in ./

You can achieve this by adjusting tflint hook configuration https://github.com/antonbabenko/pre-commit-terraform/blob/master/.pre-commit-hooks.yaml#L63-L70 like this: exclude: (\.terraform|test)\/.*$ — this will exclude all files in test/ dir in addition to excluded by default .terraform/ dir.

@grimm26
Copy link
Author

grimm26 commented Dec 13, 2021

@yermulnik Is there a way to do this in my .pre-commit-config.yaml or how can I modify the .pre-commit-hooks.yaml for myself?

@grimm26
Copy link
Author

grimm26 commented Dec 13, 2021

NM, I firgured it out. I can just add an exclude setting in the .pre-commit-config.yaml

@grimm26 grimm26 closed this as completed Dec 13, 2021
@yermulnik
Copy link
Collaborator

Great to hear you've managed this 👍🏻

@MaxymVlasov MaxymVlasov added question hook/terraform_tflint Bash hook and removed feature New feature or request labels Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants