title: Terraform nested loop in nested list
body: <p>I'm trying to create a dynamic method to create vms in multiple environments that will be configured by the end user.
  Tried for loops with nested loops. flatten function, count, etc but haven't found a way to reach my goal.
  I have terrafrom.tfvars with the follwing structure:</p>
  <pre><code>Bigip_devices = {
      main_hub = {
        region             = &quot;eastus&quot;
        azs                = [&quot;1&quot;]            #Azure availabilty zones
        vnet_name               = &quot;vnet-main&quot;   # Vnet name to deploy to
        bigip_instance_count = 2            # Number of instnaces to delpoy
        cluster             = &quot;yes&quot;         # Deploy as a cluster or stand alone device
        version             = &quot;&quot;            # Leave blank for default value
        sku                 = &quot;&quot;            # Leave blank for default value - f5-bigip-virtual-edition-25m-best-hourly
        offer               = &quot;&quot;            # Leave blank for default value - f5-big-ip-best
        instance_type       = &quot;&quot;            # Leave blank for default value - Standard_DS3_v2
        disable_password_authentication = &quot;&quot;     #Leave blank for default value
        tags                = &quot;&quot;
      }
      spoke = {
        region             = &quot;eastus&quot;
        azs                = [&quot;1&quot;,&quot;2&quot;]            #Azure availabilty zones
        vnet_name               = &quot;vnet-spoke&quot;   # Vnet name to deploy to
        bigip_instance_count = 4            # Number of instnaces to delpoy
        cluster             = &quot;yes&quot;         # Deploy as a cluster or stand alone device
        version             = &quot;&quot;            # Leave blank for default value
        sku                 = &quot;&quot;            # Leave blank for default value - f5-bigip-virtual-edition-25m-best-hourly
        offer               = &quot;&quot;            # Leave blank for default value - f5-big-ip-best
        instance_type       = &quot;&quot;            # Leave blank for default value - Standard_DS3_v2
        disable_password_authentication = &quot;&quot;     #Leave blank for default value
        tags                = &quot;&quot;
      }
    }
  </code></pre>
  <p>What is the correct method to iterate each key in the list( in the example the are 2 keys - main hub and spoke) and to create the amount of virtual machines corresponding to the <strong>bigip_instance_count</strong> setting.
  In the above example, I want to create 2 environments, one with 2 devices and the second with 4 devices.
  Is there a way to achieve it?</p>