title: Terraform - A reference to a resource type error
body: <p>Error below keeps happening. I have played around with various configurations inside this subnets_map construct and no luck. Clearly missing some fundamental aspect here. Thanks.</p>
  <pre><code>Waiting for the plan to start...
  
  Terraform v1.1.2
  on linux_amd64
  Configuring remote state backend...
  Initializing Terraform configuration...
  ╷
  │ Error: Invalid reference
  │
  │   on Modules/privateendpoints/main.tf line 36, in locals:
  │   36:       for subnets in pe_subnet : {
  │
  │ A reference to a resource type must be followed by at least one attribute
  │ access, specifying the resource name.
  </code></pre>
  <p><strong>Variables</strong></p>
  <pre><code>variable &quot;private_endpoints&quot; {
    type = map(object({
      name                = string
      resource_group_name = string
      pe_subnet = map(object({
        name                 = string
        virtual_network_name = string
        resource_group_name  = string
      }))
      subresource_name               = list(string) # https://docs.microsoft.com/en-us/azure/private-link/private-endpoint-overview#private-link-resource
      is_manual_connection           = bool
      request_message                = string # 140 character limit
      dns_zone_names                 = list(string)
      dns_zone_group_name            = string
      private_connection_resource_id = string
      tags                           = map(string)
    }))
    description = &quot;Map containing Private Endpoint and Private DNS Zone details&quot;
    default     = {}
  }
  </code></pre>
  <p><strong>Part of MAIN</strong></p>
  <pre><code>  subnets_map = distinct(flatten([
      for pesubnet_k, pesubnet_v in var.private_endpoints : [
        for subnets in pe_subnet : {
          pesubnet_key         = pesubnet_k
          name                 = pesubnet_v.name
          virtual_network_name = pesubnet_v.virtual_network_name
          resource_group_name  = pesubnet_v.resource_group_name
      }]
    ]))
  }
  </code></pre>
  <p><strong>TFVARS</strong></p>
  <pre><code>private_endpoints = {
    pe1 = {
      name                = &quot;pe-kv-eastus2-01&quot;
      resource_group_name = &quot;Terraform1&quot;
      pe_subnet = {
        name                 = &quot;pe-snet-eastus2-01&quot; # name of the private endpoint subnet
        virtual_network_name = &quot;vnet-eastus2-01&quot;    # name of the vnet the private endpoint subnet is in
        resource_group_name  = &quot;Terraform1&quot;         # rg name of the vnet
      }
      subresource_name               = [&quot;vault&quot;]
      is_manual_connection           = false
      request_message                = null
      dns_zone_names                 = [&quot;privatelink.vaultcore.azure.net&quot;]
      dns_zone_group_name            = &quot;keyvault_dns&quot;
      private_connection_resource_id = &quot;/subscriptions/xxxyyy/resourceGroups/Terraform1/providers/Microsoft.KeyVault/vaults/kv-eastus2-01&quot;
      tags = {
        pe = &quot;KeyVault&quot;
      }
    }
  }
  </code></pre>