-
Hi BICEP Community, I got an array output from calling a subnet module. -- subnet module -- resource vnet 'Microsoft.Network/virtualNetworks@2021-02-01' existing = [for vname in nets: {
name: '${vname.name}-${substring(uniqueString(resourceGroup().id), 0, 6)}'
// scope: resourceGroup(vnetRGName)
}]
output subnet array = [for (subnet, i) in nets: {
subnetId: map(vnet[i].properties.subnets, subid => subid.id)
}] -- subnet Array
[
{ 'subnetId': [ '/subscriptions/12345678-2c19-4567-1212-12345678/resourceGroups/bc-rg/providers/Microsoft.Network/virtualNetworks/vnet01-pa3vd/subnets/vnet01-snet01-pa3vd',
'/subscriptions/12345678-2c19-4567-1212-12345678/resourceGroups/bc-rg/providers/Microsoft.Network/virtualNetworks/vnet01-pa3vd/subnets/vnet01-snet02-pa3vd'
]
},
{ 'subnetId': [ '/subscriptions/12345678-2c19-4567-1212-12345678/resourceGroups/bc-rg/providers/Microsoft.Network/virtualNetworks/vnet02-pa3vd/subnets/vnet02-snet01-pa3vd'
'/subscriptions/12345678-2c19-4567-1212-12345678/resourceGroups/bc-rg/providers/Microsoft.Network/virtualNetworks/vnet02-pa3vd/subnets/vnet02-snet02-pa3vd'
]
}
] Is there any method I can convert this subnet into a single array before passing it to another module for whitelisting a network ACL in keyvault? Expected: Array as subnetId: [
'/subscriptions/12345678-2c19-4567-1212-12345678/resourceGroups/bc-rg/providers/Microsoft.Network/virtualNetworks/vnet01-pa3vd/subnets/vnet01-snet01-pa3vd'
'/subscriptions/12345678-2c19-4567-1212-12345678/resourceGroups/bc-rg/providers/Microsoft.Network/virtualNetworks/vnet01-pa3vd/subnets/vnet01-snet02-pa3vd'
'/subscriptions/12345678-2c19-4567-1212-12345678/resourceGroups/bc-rg/providers/Microsoft.Network/virtualNetworks/vnet02-pa3vd/subnets/vnet02-snet01-pa3vd'
'/subscriptions/12345678-2c19-4567-1212-12345678/resourceGroups/bc-rg/providers/Microsoft.Network/virtualNetworks/vnet02-pa3vd/subnets/vnet02-snet02-pa3vd'
] |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
please share the code you have in main. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@brwilkinson For my case, I have multiple VNETs and SubNets as you see the defined variable. would like to use the same technique to construct a new single array with all 4 SubnetId |
Beta Was this translation helpful? Give feedback.
You can use
flatten
combined withmap
. Assuming the module is namedmod
, this would look like:flatten(map(mod.outputs.subnet, s => s.subnetId))