terraform-linters / tflint

A Pluggable Terraform Linter
Mozilla Public License 2.0
4.86k stars 354 forks source link

Feature: Ability to set plugin directory #781

Closed jpreese closed 4 years ago

jpreese commented 4 years ago

TL;DR It would be nice to be able to specify where the plugins are stored. 💯

wata727 commented 4 years ago

Hi @jpreese, thank you for opening the issue.

In what situations do you think it might be useful? Also, are you assuming something like an environment variable to change the location?

jpreese commented 4 years ago

My immediate use case is using a plugin inside of a build container in a CI pipeline. I have a Dockerfile that contains both tflint and the azurerm plugin.

Unfortunately, at least with Azure DevOps, build containers in CI are always run under the user azureuser_azpcontainer. This means that my Dockerfile also has to put the plugin in this path, for that user. It's not a huge deal, but it feels slightly off to create a specific user.

# Install tflint Azure rules
RUN curl -LO https://github.com/terraform-linters/tflint-ruleset-azurerm/releases/download/v${TFLINT_AZURE_RULES_VERSION}/tflint-ruleset-azurerm_linux_amd64.zip \
  && unzip tflint-ruleset-azurerm_linux_amd64.zip \
  && chmod +x tflint-ruleset-azurerm \
  && mv tflint-ruleset-azurerm /home/azureuser_azpcontainer/.tflint.d/plugins/tflint-ruleset-azurerm

With our Terraform plugins, we just always put them in /opt and set the TF_PLUGIN_CACHE_DIR variable.

To answer your last question, yes, I was thinking the typical approaches: environment variable, something we can set inside of .tflint.hcl, and/or a flag on tflint itself.

wata727 commented 4 years ago

Thank you for the explanation. It makes sense. Probably it would be good to be able to change it with an environment variable like TFLINT_PLUGIN_DIR.