Error referencing builtin module output

i’m using this registry module that declare a resource that use for_each:
Captura de pantalla 2024-08-20 145555
and referencing the output that terraform provides as

subnet_id = module.vnet1.vnet_subnets[“subnet1”]

but i’m getting the following error, (but the output is in registry and i’ve referenced it right)
│ Error: Unsupported attribute

│ on vms.tf line 306, in resource “azurerm_network_interface” “nic3”:
│ 306: subnet_id = module.vnet1.vnet_subnets[“subnet1”]
│ ├────────────────
│ │ module.vnet1 is object with 7 attributes

│ This object does not have an attribute named “vnet_subnets”.
i will be so glad if anyone can give me a possible answer for this issue

Hi @ignacio.genzor,

I can’t give a precise answer without the missing information, like what are the module instances, what are the actual module outputs (i.e. what is the type and value of vnet_subnets), and what is the end result you are trying to get.

I can tell from your example that you have a module named module.vnet1, which is expanded using for_each, so that address must always be followed by an index to refer to the module instance:

module.vnet1["something"].vnet_subnets