Nesting loop with result of for_each

Might be helpful to include the way you’re trying to use the resulting data structure?

What I usually do in cases like this is first figure out how the data should be structured, and then setup a self-contained tf file with just the starting point and an output with the data structure I want. That way, I can play around with different things quickly.

Because of Terraform’s weird pseudo-iteration, there is sometimes a lot of this necessary (wrangling from one data structure to another). Figuring out the structure you need is often half the battle.

I put an example of this here, just in case that helps.

Also, is your original data structure more complicated than in the example above? I would probably tend to just make a set of instance names vs. a list of objects, unless you’ve also got additional information stuffed in there besides name?