-
Notifications
You must be signed in to change notification settings - Fork 10.3k
empty list comparison does not work if the list contains an object #23562
Copy link
Copy link
Closed
Labels
Description
Terraform Version
Terraform v0.12.17
Terraform Configuration Files
Thanks @dpiddockcmp for a simpler example. #23562 (comment)
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"
}Expected Behavior
Outputs:
equal = empty
not_equal = empty
Actual Behavior
Outputs:
equal = not empty
not_equal = not empty
Steps to Reproduce
terraform init
terraform apply -auto-approve
Solution
variable "object" {
type = list(object({ a = string }))
default = []
}
output "equal" {
value = length(var.object) == 0 ? "empty" : "not empty"
}
output "not_equal" {
value = length(var.object) != 0 ? "not empty" : "empty"
}References
Reactions are currently unavailable