mschuchard / linter-terraform-syntax

terraform validate linter and formatter for pulsar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please add an exclude files/directories feature

iggy opened this issue · comments

This is a minor annoyance, but it would be awesome to be able to tell the package to ignore certain directories (and maybe files). My main reason for requesting this is that the package tries to run in my module directories and throws quite a few errors that it really shouldn't (i.e. missing modules that are installed in the root module, not in the module directory where the file is located; etc.).

Let me know if you have any questions.

Terraform should really be able to find those modules I would think, but what I can basically do for this is what I did for the ansible-lint package where you can create a regular expression "blacklist" that the linting will ignore.

Example: The ansible-lint blacklist would be (travis|docker) to avoid travis and docker-compose configs.

This is what could generally be implemented for this. Would that work?

I think that would work perfectly. All of my modules are in a modules/ dir in my repos, so should be easy enough to ignore that entire path.

I just re-read my original post and realize it might be a bit confusing (made perfect sense at the time 🤣 )

To clarify what I was talking about above, imagine a dir structure like the following.

.
|____eks-dev.tf
|____modules
| |____eks
| | |____outputs.tf
| | |____main.tf
| | |____variables.tf

When I run terraform validate in the top level dir, it runs fine because it has the aws provider, etc there. When the linter-terraform package tries to run terraform validate in the modules dir it fails because it's missing providers and other stuff that is in the top-level dir.

I just want it to ignore the modules dir altogether.

Hope that helps.

Sure, adding this to my TODO.

Added in 1684794. You can "patch" this into your current package by replacing the linter-terraform-validate/lib/main.js with the one from this repo.