What is the splat expression and what does `one()` add?
AdvancedConceptLoops, Conditionals, Dynamic Blocks and Functions
Answer
aws_instance.web[*].id collects an attribute from every instance into a list. It also turns a single object or null into a list of zero or one elements, which is why one(aws_eip.nat[*].id) returns the value or null for resources with a count toggle. one() errors if the list has more than one element.
More on Loops, Conditionals, Dynamic Blocks and Functions
How does `count` work?BeginnerHow does `for_each` work?BeginnerWhen should you choose `for_each` over `count`?IntermediateHow do you use `for_each` with a list of objects?IntermediateWhat does "The for_each value depends on resource attributes that cannot be determined until apply" mean?AdvancedHow do you create a resource conditionally?Beginner