It’s kind of possible, but not particularly nice, or easy.
You do indeed use for_each
, but this is only capable of one level of looping. Which means that you have to use the Terraform expression language to flatten all the looping you want to do into a single map - and pass that to for_each
.
Here is an example I wrote recently: Multiple iteration in one resource - #2 by maxb