tflint
tflint copied to clipboard
tflint docker plugin management
Introduction
We are using the docker image ghcr.io/terraform-linters/tflint-bundle
currently in our pipelines to check our code. This is deprecated and we should use the plugin management instead. The docker command provided automatically removes the image (and even without it) running docker run --rm -v $(pwd):/data -t ghcr.io/terraform-linters/tflint --init && docker run --rm -v $(pwd):/data -t ghcr.io/terraform-linters/tflint --recursive
fails with
Failed to run in .; exit status 1
Failed to initialize plugins; Plugin "azurerm" not found. Did you run "tflint --init"?
Proposal
I think we should state a recommended way to work with docker and plugins. My current idea is to force the plugins directory into the pwd by either creating the folder or setting it in config
config {
plugin_dir = "./.tflint.d/plugins"
}
Another way would be to allow running init and scan in the same command. This can be archived by overwriting the entry point and running tflint via sh docker run --rm -v "$(pwd):/data" --entrypoint=/bin/sh ghcr.io/terraform-linters/tflint -c "tflint --init && tflint --recursive"
I'm not sure, what is better/should be the recommended way.
References
- https://stackoverflow.com/questions/72075996/how-to-run-tflint-docker-passing-multiple-args