feat: add support for Terraform modules in tflint #2297
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes
tflint
path errors when files and modules are referenced in a relative directory in Terraform and enablestflint
module mode usage.tflint
has to be run from the same directory as the file under test in order for relative references to work correctly.I'm not sure if there are other updates that need to be made to the tests so I'd appreciate some guidance there. I added some Terraform that seems like the right test structure to me, but I'm perfectly happy to change it. The image built and
make test
returned successfully locally.I feel a little weird about where
terraform get
is right now but it does work. If you'd like I can try to determine if module mode is enabled and add it toLINTER_COMMAND
forTERRAFORM_TFLINT
.Proposed Changes
tflint
terraform get
before runningtflint
terraform
binary to support thisExample
File structure of the project
Where
src/environment/service/main.tf
contains.github/linters/.tflint.hcl
containsTesting
Current build
Build with this change
I tagged the image as
super-linter-test
Inserting errors
Just to make sure I wasn't arbitrarily making the linter pass, I removed the
version
from thegood_reference
moduleI also broke the relative module reference by choosing an invalid path
../../../broken/path/mymodule
Readiness Checklist
Author/Contributor
Reviewing Maintainer
breaking
if this is a large fundamental changeautomation
,bug
,documentation
,enhancement
,infrastructure
, orperformance