-
-
Notifications
You must be signed in to change notification settings - Fork 998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terragrunt and TFLint above 0.50.0 breaking behavior #3669
Comments
Hey @velkovb , Thanks for creating this issue. Unfortunately, given that there's a very straightforward workaround (calling tflint with the binary installed in PATH however users like), there isn't much incentive to adjusting how the built-in That being said, if this issue is important to you, would you consider contributing the code required to have Our focus is on delivering the features and updates that make Terragrunt ready for 1.0, so I'm jealously guarding the attention of the maintainers for that when I can. I hope you understand. |
@yhakbar Thanks for getting back to me. Initially, I started using the built-in Giving it a go crossed my mind. Might try it over the holidays :) |
Ya, I was discussing the Please make sure to read these docs before you start contributing so that you have some guidance on how to get started. The steps I generally recommend for new contributors is to start with the following:
I also heavily encourage you to join the Discord if you haven't. This can be a good place to ask questions about best practices, or to just become an active member of our community. |
Thanks, already in discord :). My journey started because I actually wanted a newer version of TFLint that includes this fix - terraform-linters/tflint#2124 as we had problems with auto generated providers. So I will try to push forward |
@yhakbar I would guess that this logic is already implemented where the inputs are transformed for OpenTofu/ Terraform somewhere in the codebase. I could find it on my first attempt, could I ask for some directions where it is? |
hey, Have you already read the main function where the https://github.com/gruntwork-io/terragrunt/blob/main/tflint/tflint.go#L31 |
We ended up with just calling TFLint with a custom hook, not the integrated one as we were not using the variables anyway. We have plans to enchance TFLint performance in the future and might revisit this than. |
Hello,
Right now I installed locally TFLINT 0.49.0 and I added the Can I ask you what is your solution about the custom hook? Is there a way to tell TFLint to simply ignore this specific rule?
? Thank you |
terraform {
before_hook "tflint" {
commands = ["validate"]
execute = ["${get_repo_root()}/scripts/tflint.sh", "${get_repo_root()}/deployment/.tflint.hcl"]
}
} #!/bin/bash
tflint --init --config ${1} |
@velkovb Thank you. This is a mere alternative on using "--terragrunt-external-tflint" or does it actually solve the problem I mentioned of variable assigned and not deckared? Thank you |
This doesn't use the Terragrunt integrated TFLint hook which actually passed the assigned variables so it doesn't have that problem. The issue here is it strips all variables even some that might have been actually used but that works for us for now. As described previously we plan on either trying to add an option to pass the variables as |
I'm not sure how this can work, you only provide the --config so that you can install the plugins. Right now I found this combination to be working properly:
and this
I removed --init from your example because with that it was only initializing but the analysis was not performed (and no errors) |
Describe the enhancement
TFLint introduced a new way of handling values for undeclared variables in 0.50.0 - terraform-linters/tflint#1941
This directly affects the Terragrunt hook integration as it does the following:
tflint --config ./.terragrunt-cache/ellCj9USNaAqucT2-U5SmL6rf1A/Gu7P37gZ1L3NBihh7GJE9nHhW38/.tflint.hcl --chdir ./.terragrunt-cache/ellCj9USNaAqucT2-U5SmL6rf1A/Gu7P37gZ1L3NBihh7GJE9nHhW38 --var=test=foo
With Terragrunt release of
0.69.0
which bumped TFLint from 0.47.0 to 0.50.3 this started breaking our projects. We do generate a lot of metadata and automatic variables that are not used by every project. terraform-linters/tflint#2080 (comment)The way that variables are passed to TFLint doesn't match the way they are passed to OpenTofu/ Terraform. For TFLint it seems to be with
--var
while for the latter it isTF_VAR_*
which has no issues. If we pass OpenTofu/Terraform with--var
it will error out as well.Would be great if we can align both approaches and pass variables from input to TFLint as TF_VAR_* as well. If that cannot be done, passing a
.tfvars
file should work as well. I would guess the magic needs to happen somewhere here -terragrunt/tflint/tflint.go
Line 154 in 407f65f
Not sure if this is a bug or enhancement
Additional context
Things you might want to address include:
PoC (Proof of Concept)
Link to a Proof of Concept if you have one:
Including a PoC can help others understand the feature better and implement it faster.
RFC Not Needed
The text was updated successfully, but these errors were encountered: