Closed ahmad-hamade closed 1 year ago
Please note, the issue is reported only when I use a custom terraform module that has the following values:
external_dns = {
enabled = true
domain_names = keys(module.base_dns_zone.route53_zone_name)
domain_name_arns = values(module.base_dns_zone.route53_zone_zone_arn) # <---- this line is what causing the problem
}
If I omit the value for domain_name_arns
property then tflint
works just fine.
Below is the external_dns
variable definition:
variable "external_dns" {
type = object({
enabled = bool
domain_names = list(string)
domain_name_arns = optional(list(string), [])
helm_version = optional(string, "1.13.0")
})
description = "External DNS configuration"
default = null
}
Thank you for reporting this. This seems like a bug.
In TFLint an expression like module.base_dns_zone.route53_zone_zone_arn
always resolves to an unknown value of an unknown type.
https://github.com/terraform-linters/tflint/blob/dcc49cefef705925dbf7003d41889059421277e8/terraform/lang/eval.go#L189
Next, HCL v2.17, which is used in TFLint v0.47, introduces the concept of refinements. This seems to apply implicit refinements when default values such as optional(list(string), [])
are applied.
Unfortunately refinements for unknown values of unknown types don't seem to be supported. https://github.com/zclconf/go-cty/blob/v1.13.3/cty/unknown_refinement.go#L46-L47
I'm not sure how to fix this, but it might be a good idea to fix the HCL to not apply the refinement in case of unknown values of unknown types.
The current workaround is to downgrade to TFLint v0.46.1.
The upstream bug is fixed in https://github.com/hashicorp/hcl/pull/625 This issue is expected to be resolved by updating to the latest HCL version (unreleased).
Thank you @wata727 for the fix. I can confirm the issue is resolved in tflint v0.48.0.
Summary
TFLint started crashing after we upgraded from
0.46.1
to0.47.0
Command
tflint --config=/infra/.tflint.hcl -f compact
Terraform Configuration
TFLint Configuration
Output
TFLint Version
0.47.0
Terraform Version
1.5.2
Operating System