Why does a conditional with different object types produce "Inconsistent conditional result types"?
AdvancedConceptVariables, Locals, Outputs and Types
Answer
Both branches of cond ? a : b must convert to a common type. Two objects with different attributes do not unify, so Terraform errors. Solve by returning the same shape in both branches (use null or empty values), wrapping the result in tomap/jsonencode, or by moving the choice to a for_each or count toggle on the resource.
More on Variables, Locals, Outputs and Types
How do you declare an input variable?BeginnerIn what order does Terraform load variable values?BeginnerHow do you define an output and what is it for?BeginnerWhat is the difference between locals and variables?BeginnerWhat are the primitive types in Terraform?BeginnerHow do list, set and map differ?Intermediate