Interview Prep/Terraform/Loops, Conditionals, Dynamic Blocks and Functions

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.

All Terraform questions Roadmap: Terraform

More on Loops, Conditionals, Dynamic Blocks and Functions