terraform-linters / tflint

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

.tflint.hcl missing error with module and recursive mode since 0.50.0 bugfix #1952

Closed tommyallieri closed 10 months ago

tommyallieri commented 10 months ago

Summary

since the introduction of https://github.com/terraform-linters/tflint/pull/1940, which throws an error if .tflint.hcl is missing, it is now expecting a .tflint.hcl file in every sub-directory when using the following

tflint --config .tflint.hcl --module --recursive
Failed to load TFLint config; failed to load file: open .tflint.hcl: no such file or directory working_dir=modules

I tried adding to the modules directory, but it then errors out on the next one underneath

.tflint.hcl files shouldn't be recursively set in every sub-directory, it's not scalable. either bugfix should be removed and warn instead, or configuration should be inherited from the top, unless there's a flag I'm not seeing which would resolve this bug

Command

tflint --config .tflint.hcl --module --recursive

Terraform Configuration

N/A

TFLint Configuration

plugin "terraform" {
  enabled = true
  preset  = "recommended"
}

plugin "aws" {
  enabled = true
  version = "0.27.0"
  source  = "github.com/terraform-linters/tflint-ruleset-aws"
}

Output

[...]
09:45:39 [DEBUG] host2plugin/client.go:124: starting host-side gRPC server
09:45:39 [DEBUG] go-plugin@v1.6.0/grpc_stdio.go:142: stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
09:45:39 [INFO]  go-plugin@v1.6.0/client.go:780: plugin process exited: plugin=/usr/local/bin/tflint id=56
09:45:39 [DEBUG] go-plugin@v1.6.0/client.go:558: plugin exited
09:45:39 [DEBUG] go-plugin@v1.6.0/grpc_stdio.go:142: stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
09:45:39 [INFO]  go-plugin@v1.6.0/client.go:780: plugin process exited: plugin=/root/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.27.0/tflint-ruleset-aws id=66
09:45:39 [DEBUG] go-plugin@v1.6.0/client.go:558: plugin exited
09:45:39 config.go:143: [INFO] Load config: .tflint.hcl
Failed to load TFLint config; failed to load file: open .tflint.hcl: no such file or directory working_dir=modules

TFLint Version

0.50.0

Terraform Version

No response

Operating System

tommyallieri commented 10 months ago

a workaround is to specify the full, rather than relative path to .tflint.hcl

tflint --config "$(pwd).tflint.hcl" --module --recursive
wata727 commented 10 months ago

If you just want to ignore instead of returing an error if .tflint.hcl doesn't exist in a sub-directory, you can simply remove --config .tflint.hcl. See also https://github.com/terraform-linters/tflint/issues/1926

Discussion on configuration inheritance is tracked in https://github.com/terraform-linters/tflint/issues/1929.