-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
empty list comparison does not work if the list contains an object #23562
Comments
Hi, this is more generic that the reporter implies. Empty list comparison does not work if the list contains an object: variable "object" {
type = list(object({ a = string }))
default = []
}
output "equal" {
value = var.object == [] ? "empty" : "not empty"
}
output "not_equal" {
value = var.object != [] ? "not empty" : "empty"
}
|
ok, i was testing only yamlencode, let me change the title. Updating my example with @dpiddockcmp as the his generic example is simple and clear |
Hi @shanmugakarna, Thanks for filing the issue. The comparison here is failing because the equality operator first compares types. The type of The preferred way to check for an empty set or series of any type would be to check its length, rather than compare it against a literal value
There are however some cases where comparison against a literal value may be quite useful. In these cases we will need to decide on and implement a limited set of automatic type conversion rules for comparing equality. Related: #21978 |
Hi @jbardin Thank you. I already have the |
List comparisons are broken regardless of it being type object or not, see: #29187 |
Terraform Version
Terraform Configuration Files
Thanks @dpiddockcmp for a simpler example. #23562 (comment)
Expected Behavior
Actual Behavior
Steps to Reproduce
Solution
References
terraform-aws-modules/terraform-aws-eks#606 (comment)
The text was updated successfully, but these errors were encountered: