Closed MaxymVlasov closed 1 year ago
This is an issue with the terraform_deprecated_index
rule. The WalkExpression
function walks expressions recursively, as documented:
https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.2.2/rules/terraform_deprecated_index.go#L56
https://pkg.go.dev/github.com/terraform-linters/tflint-plugin-sdk@v0.15.0/tflint#Runner
The check is probably performed 4 times, including the expressions inside local.create_namespace ? join("", kubernetes_namespace.default.*.id) : var.kubernetes_namespace
.
Summary
Looks like TFlint separates
local.kubernetes_namespace
definition to all possible programming branches, execute them it TF way (executing true and false both), and then just sends all found errors without deduplicationBecause:
on
kubernetes_namespace = local.create_namespace ? join("", kubernetes_namespace.default.*.id) : var.kubernetes_namespace
onkubernetes_namespace = local.create_namespace ? kubernetes_namespace.default.*.id : var.kubernetes_namespace
it sends 4 duplicated errorskubernetes_namespace = local.create_namespace ? join("", kubernetes_namespace.default.*.id) : ""
onkubernetes_namespace = local.create_namespace ? kubernetes_namespace.default.*.id : ""
it sends 3 duplicated errorson
kubernetes_namespace = true ? join("", kubernetes_namespace.default.*.id) : var.kubernetes_namespace
onkubernetes_namespace = false ? join("", kubernetes_namespace.default.*.id) : ""
onkubernetes_namespace = join("", kubernetes_namespace.default.*.id)
etc. with predefined/no branching it sends only 1 error, as expectedCommand
tflint
Terraform Configuration
TFLint Configuration
It reproduced without any TFlint configs too.
Output
TFLint Version
0.45.0
Terraform Version
1.3.9
Operating System
5.4.72-microsoft-standard-WSL2
)