terraform-linters / tflint

A Pluggable Terraform Linter
Mozilla Public License 2.0
4.98k stars 357 forks source link

Ability to target it for a specific directory in a project folder. when using the `--recursive` flag #1919

Closed SharkyND closed 1 year ago

SharkyND commented 1 year ago

Introduction

Currently, the --recursive flag only works with --filter if an exact file is mentioned. For example:

tflint --recursive --filter main.tf

But if we want to filter based on a certain subdir in a project folder, it doesn't work.

Working with --recursive and --chdir gives the following error:

➜ tflint --chdir='./test_tf_1/' --recursive
Failed to find workspaces; cannot use --recursive and --chdir at the same time

Proposal

For the following configuration: if we have two folders under a project folder:

|── test_tf_1 | └── main.tf | └── .tflint.hcl |── test_tf_2 │ └── main.tf │ └── .tflint.hcl

We want to target .tf files in test_tf_1 only, how will be able to achieve that? In this case scenario, something like this could really help tflint --recursive --filter ./test_tf_1/.. or tflint --chdir='./test_tf_1' --recursive when running from the root of the project.

References

This request was initially raised as a bug issue first: