Closed rdimartino closed 4 months ago
Related discussions: https://github.com/terraform-linters/tflint/discussions/1920 https://github.com/terraform-linters/tflint/discussions/1960
If terraform fmt
can use --chdir
and --recursive
together, I support this proposal in terms of interface consistency.
Introduction
Terraform allows using both the
-chdir
and-recursive
flags, e.g.terraform -chdir=infra/ fmt -check -recursive
I expected to be able to do something similar with TFLint, but got an error
I am running my formatters/linters from the project root for other tools but am having trouble doing that with TFLint.
My directory structure looks similar to
The specifics are not important, but the general problem is that running
tflint --chdir infra/
seems to only checkinfra/main.tf
, but runningtflint --recursive
ends up wasting a ton of time scanningnode_modules/
,tmp/
, and other large directories without any terraform configuration.As a work-around, I can
cd
into theinfra/
directory before runningtflint --recursive
, but I would expect this tool to work similarly to terraform and allow me to specify--chdir infra/
and--recursive
to tell TFLint to start recursing from theinfra/
directory.Proposal
Allow the use of both
--chdir
and--recursive
together.Recursion should start from the directory specified by the
--chdir
flag.References
https://github.com/terraform-linters/tflint/issues/1304#issuecomment-1907277718
https://developer.hashicorp.com/terraform/cli/commands/fmt#recursive