Using Terraform 0.13.X Module for_each

Hello! I am curious if I can get any advice with something I am trying to do with TF 0.13 Module for_each.

I have the following config:

I use the for_each for the module call:

The for_each will work for my namespaces:

But not sure how to syntax the for_each on the topics, when my config format is that way.

The following is how I am resolving this, but curious if there is a better way:

After changing my config to:

Again curious if this is how I need to have my config, or if there is a way to get my first config format working, as it would be preferred.

Actually the plan worked but the deploy failed due to the “parent resource” not being available, so I still need to figure out how to properly do the for_each on the topic resource.

The following is what I am doing for now with my config and module:

For anyone that happens to stumble on this post I was able to resolve it via flatten() with locals, which I had never used before.


Module Call:




Service Bus Namespace Resource Block:

Service Bus Namespace Topic Resource Block:

Service Bus Namespace Topic Subscription Resource Block: