What does `setproduct` give you?
IntermediateConceptLoops, Conditionals, Dynamic Blocks and Functions
Answer
It returns every combination of elements from the input sets or lists, useful for cross-products such as environments by regions or subnets by route tables.
for_each = { for p in setproduct(var.envs, var.regions) : "${p[0]}-${p[1]}" => p }
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