https://pulumi.com logo
#general
Title
# general
c

colossal-room-15708

04/06/2019, 1:13 PM
Can I somehow get to the
id
property of the nested subnet resource of an Azure vnet?
Copy code
const vnet = new azure.network.VirtualNetwork("vnet", {
    resourceGroupName: resourceGroup.name,
    location: region,
    name: "vnet",
    addressSpaces: [addressSpace],
    subnets: [
        {
            addressPrefix: addressPrefix1,
            name: "management"
        }
    ]
})
Creating a subnet like this is allowed, but I wonder if I need to actually get to any information about this subnet in the same stack if it would be better to use the Subnet resource, instead of this nested syntax here. Or is there a way to get to that nested resource?
w

white-balloon-205

04/06/2019, 6:00 PM
I believe you can get it with:
Copy code
vnet.subnets[0].id
c

colossal-room-15708

04/07/2019, 8:39 AM
yes, that works, however, ideally I'd like to run a
.filter()
on
vnet.subnets
to find the correct subnet by name. That doesn't seem to work though with a type error.
I worked around this by moving the vnet creation into a component and outputting each subnet, that way I can now do
vnet.mgmtSubnet
for example