Failed to initialize a runner; number value is required #1545
-
IntroductionHello, I'm setting up Debug output
$ tflint -v
TFLint version 0.41.0
$ terraform -v
Terraform v1.3.2
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.34.0
+ provider registry.terraform.io/hashicorp/template v2.2.0 |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
Not reproducible with an empty module, albeit on darwin_arm64 instead of amd. A reproducible report is needed. |
Beta Was this translation helpful? Give feedback.
-
I can reproduce this with 0.41 but not with 0.40. Not sure why this was turned into a discussion topic. I'll try to update this thread later today with more debugging info. So far I can reproduce it inside an Alpine 3.16 container with tflint 0.41... but not outside on a Fedora 36 system. |
Beta Was this translation helpful? Give feedback.
-
The issue seems to be when a string variable is passed to count. Fails:
Works:
|
Beta Was this translation helpful? Give feedback.
-
Let me fully acknowledge the TF code is wrong but terraform 1.x seems very forgiving and does what is expected. We'll be fixing our code thanks for this error with tflint but I'm wondering what tflint does differently from terraform itself in this case. |
Beta Was this translation helpful? Give feedback.
-
I've managed to replicate the issue. The original code was: variable "redis_number_of_nodes" {
description = "The number of cache nodes within the ElastiCache cluster. This number must be greater or equal 2 to enable automatic failover."
type = string
default = "1"
}
variable "redis_snapshot_retention_limit" {
description = "The number of days for which automated backups are retained. Setting this parameter to a positive number enables backups. Setting this parameter to 0 disables automated backups"
type = string
default = "7"
} The new code is: variable "redis_number_of_nodes" {
description = "The number of cache nodes within the ElastiCache cluster. This number must be greater or equal 2 to enable automatic failover."
type = number
default = 1
}
variable "redis_snapshot_retention_limit" {
description = "The number of days for which automated backups are retained. Setting this parameter to a positive number enables backups. Setting this parameter to 0 disables automated backups"
type = number
default = 7
} The issue is that the type for the variable was wrong, and the default matched the defined type, not the type associated with the usage (which, in this case, was both numeric). It would seem that strings, containing numbers, are treated as valid by Terraform (the really painful art of type juggling ... yeah!), but TFLint does the right thing (in my mind) and says "Nope" to them. What would have been useful was to output SOMETHING about the actual error trigger. |
Beta Was this translation helpful? Give feedback.
-
Summary
|
Beta Was this translation helpful? Give feedback.
Summary
count
are anumber
, which is the expected typenumber
(string
), that TFLint now doesn't is an unintended regression