Closed spkane closed 2 years ago
This error seems to make sense. I think this is because null is passed as an argument that should not be passed when calling the module (to be exact, the default value is used by omitting the argument). You probably get the same error when you run terraform plan
.
So, I actually get the warning twice. Once for a module that we have, which actually directly uses the upstream module, and is located in _tf_modules/k8s/
, and once for the terraform code that calls that module located in environments/cluster-automation-sandbox/k8s/poc/
.
TFLint in _tf_modules/k8s/:
Failed to prepare rule checking; failed to eval an expression in .terraform/modules/k8s-addons/modules/kubernetes-addons/helm-addon/main.tf:66; Attempt to get attribute from null value: This value is null, so it does not have any attributes.
TFLint in environments/cluster-automation-sandbox/k8s/poc/:
Failed to prepare rule checking; failed to eval an expression in .terraform/modules/k8s-addons/modules/kubernetes-addons/helm-addon/main.tf:67; Attempt to get attribute from null value: This value is null, so it does not have any attributes.
I can run terraform plan
just fine inside of environments/cluster-automation-sandbox/k8s/poc/
and DO NOT get the null error.
Since _tf_modules/k8s/
is just a module, I can't directly run terraform plan
inside it, as the provider is unconfigured and some variables would need setting.
Understood. In this case, I recommend removing the default value from the irsa_config
variable. The default value is null, but obviously it's not supposed to use as null (it looks like a de facto required variable).
My recommendation is to fix the upstream module, but if it's difficult, I have no choice but to ignore inspection for the module.
I checked the module again, but it seems that the problem is that TFLint evaluates module arguments without considering the count
argument.
I haven't confirmed the behavior, but Terraform may not evaluate arguments if the module's count
is 0. In that case, TFLint should also be fixed to follow the semantics.
I have just tested this and indeed it appears to have solved the original issue. Thank you very much for getting this in!
I have an upstream module that I am using which causes this error when linting.
The module has this variable defined:
which is then referenced here:
and this generates the above error during linting.
The terraform code works in general.
Is there a way to fix this in
tflint
, ignore this error, or ignore this specific module or file?Version