Loading...
Loading...
### Terraform Version ```shell 1.4.6 ``` ### Terraform Configuration Files ```terraform locals { list_object_a_enabled = true list_object_a = tolist([ { id = "a" enabled = true nested = { nested_id = 0 nested_class = "test" } } ]) list_object_b = tolist([ { id = "b" enabled = true expiration = { days = 31 } } ]) list_of_objects_ternary = local.list_object_a_enabled == true ? concat(local.list_object_a, local.list_object_b) : local.list_object_b list_of_objects_ternary_with_tolist = local.list_object_a_enabled == true ? tolist(concat(local.list_object_a, local.list_object_b)) : local.list_object_b list_of_objects_ternary_false = local.list_object_a_enabled == false ? concat(local.list_object_a, local.list_object_b) : local.list_object_b } ``` ### Debug Output ``` │ Error: Inconsistent conditional result types │ │ on main.tf line 58, in locals: │ 58: list_of_objects_ternary = local.list_object_a_enabled == true ? concat(local.list_object_a, local.list_object_b) : local.list_object_b │ ├──────────────── │ │ local.list_object_a is list of object with 1 element │ │ local.list_object_a_enabled is true │ │ local.list_object_b is list of object with 1 element │ │ The true and false result expressions must have consistent types. The 'true' value is tuple, but the 'false' value is list of object. ╵ ╷ │ Error: Invalid function argument │ │ on main.tf line 59, in locals: │ 59: list_of_objects_ternary_with_tolist = local.list_object_a_enabled == true ? tolist(concat(local.list_object_a, local.list_object_b)) : local.list_object_b │ ├──────────────── │ │ while calling tolist(v) │ │ local.list_object_a is list of object with 1 element │ │ local.list_object_b is list of object with 1 element │ │ Invalid value for "v" parameter: cannot convert tuple to list of any single type. ╵ ╷ │ Error: Inconsistent conditional result types │ │ on main.tf line 60, in locals: │ 60: list_of_objects_ternary_false = local.list_object_a_enabled == false ? concat(local.list_object_a, local.list_object_b) : local.list_object_b │ ├──────────────── │ │ local.list_object_a is list of object with 1 element │ │ local.list_object_a_enabled is true │ │ local.list_object_b is list of object with 1 element │ │ The true and false result expressions must have consistent types. The 'true' value is tuple, but the 'false' value is list of object. ``` ### Expected Behavior If I concat lists, I expect a list to be returned, not a tuple. This seems to result from complex objects (like nested maps) being involved in the concatenation. I haven't noticed this if the lists contained string or bool or int. Perhaps this has already been found or the behavior is expected. ### Actual Behavior See errors ### Steps to Reproduce Attempt to concat two lists that contain complex objects (like a map) ### Additional Context It'd be useful to concat these types of objects together, particularly in use for modules. I have lists containing complex object variables I'm trying to pass into modules and then perform some modifications on top of those variables if certain conditions are met. Sometimes these variables have a certain nested map in them, sometimes they don't. Sometimes it might just be string fields instead of string fields + map objects within an object in the list. ### References _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.