-
Notifications
You must be signed in to change notification settings - Fork 359
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
Add support --recursive
option
#841
Conversation
I've encountered this problem before and have typically included Terraform specific logic in the directory finding, usually checking for Given that multiple tools are likely to be involved in validation (e.g., |
Thank you for your comment. Yes, I'm also wondering if this problem should be fixed with TFLint. Probably, users also have similar issues with |
I currently work in an active monorepo at @TakeScoop FWIW, and we just have a shell script handling this at the moment. The landscape for Terraform static validation is a little patchy, particularly with some rough edges in |
Dose it also work with modules and submodules? This will be very important for me, because my code are structured like java packages by using modules. |
Please build and try this on your project, hard to comment without a reproducible example. |
A related thought I've had that might be relevant is looking upward for config and merging, like git does with configuration files like gitignore. This would allow for a top level TFLint configuration in the repo root, overrides for specific modules in their directories, and make it viable to run |
That change conflicts a bit with existing config handling but a WIP that I tested against a real monorepo worked as expected: https://github.com/terraform-linters/tflint/tree/walk-up-config |
Here is some example how i use terraform
In Main.tf there are just instance of modules
for me it's the best way to structure compoments of terraform code. |
That example would be a good fit for TFLint as it exists today. If you invoke TFLint on the root directory with This feature would be needed for cases where you have lots of modules that don't share a Terraform entrypoint. In your example, if |
Fixes #527
This is a PoC of recursive directory scanning. I've heard that for large projects there are cases where you want to run tflint in a different context than terraform apply. In such cases, it doesn't make us happy to maintain a shell script that walks directories and runs tflint in each directory.
Run with the
--recursive
option to walk each directory and run the analysis:However, recursive mode has some limitations:
terraform.*
andpath.*
are ignoredThese are necessary to run in a different context than Terraform. However, I'm not sure if it can solve the problems of users with complex project structures when there are these limitations. I welcome feedback on this matter.