Referring to Instances from a foreach loop

Hello
im using a For_each in a resource to create 2 or more of those resources. in my case this is resource

  • “azurerm_virtual_network”

I then setup my subnets resource “azurerm_subnet” and im trying to reference

  • virtual_network_name = azurerm_virtual_network.new[].name

according to the doco (https://www.terraform.io/docs/configuration/resources.html#count-multiple-resource-instances) Instances are identified by a map key (or set member) from the value provided to for_each
.[] (for example, azurerm_resource_group.rg[“a_group”], azurerm_resource_group.rg[“another_group”], etc.) refers to individual instances.

can you help me understand the because when i use it in this way i get
| azurerm_subnet.subnet1 is object with 10 attributes
| each.key is “dev”

The given key does not identify an element in this collection value.