super-linter: tflint failing in slim-v4.9.3 "Plugin `aws` not found in /github/home/.tflint.d/plugins"

Describe the bug

We’re running super-linter on our codebase that is largely made up of terraform files. it has just failed with error:

2022-05-24 20:26:03 [INFO]   File:[/github/workspace/repo/path/to/file.tf]
2022-05-24 20:26:03 [ERROR]   Found errors in [tflint] linter!
2022-05-24 20:26:03 [ERROR]   Error code: 1. Command output:
------
Failed to initialize plugins; Plugin `aws` not found in /github/home/.tflint.d/plugins

Note that we don’t use AWS, we don’t use any AWS terraform providers.

I note that this is running on v4.9.3:

Status: Downloaded newer image for ghcr.io/github/super-linter:slim-v4.9.3

I have compared to a successful run of the super-linter 6 horus ago which also used tflint to lint some terraform code, it is using an earlier version of the super-linter:

Status: Image is up to date for ghcr.io/github/super-linter:slim-v4.9.2

Expected behavior

This error should not occur. We haven’t done anything to cause it and it does look as though its been caused by the bump to v4.9.3.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 11
  • Comments: 25 (10 by maintainers)

Most upvoted comments

As an aside (whilst waiting for the fix to be released) I’ve also found that setting plugin_dir = "/root/.tflint.d/plugins" in a custom .tflint.hcl file also resolves this issue, for example:

config {
  module     = true
  plugin_dir = "/root/.tflint.d/plugins"
}

Having this file also allows you to enable other rules for this linter, as very few are actually enabled by default.

@admiralAwkbar @ferrarimarco I think I found the solution, to take with a grain of salt given I am neither very familiar with super-linter internals nor tflint. Setting TFLINT_PLUGIN_DIR to /root/.tflint.d/plugins does the trick.

Observations:

  • tflint --init seems to be used to download plugins, given aws is manually installed by tflint-bundle, I dont think it plays a role here
  • HOME is set to /github/home so tflint look for plugins in /github/home/.tflint.d/plugins instead of /root/.tflint.d/plugins where they actually are.

Now the question is whether we should set TFLINT_PLUGIN_DIR to /root/.tflint.d/plugins or to something else and move the directory there (for example /usr/lib/.tflint.d/plugins)