terraform-linters / tflint

A Pluggable Terraform Linter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

tommyallieri opened this issue · comments

Summary

since the introduction of #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

  • Linux
  • macOS
  • Windows

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

tflint --config "$(pwd).tflint.hcl" --module --recursive

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 #1926

Discussion on configuration inheritance is tracked in #1929.