Skip to content

Instantly share code, notes, and snippets.

@larryclaman
Created August 19, 2021 15:44
Show Gist options
  • Save larryclaman/347d8647555fd014223baf3615c77e49 to your computer and use it in GitHub Desktop.
Save larryclaman/347d8647555fd014223baf3615c77e49 to your computer and use it in GitHub Desktop.
bicep create subnets from loop
// from https://github.com/Azure/bicep/discussions/3449
var addressSpace = [
'10.144.0.0/16'
]
var subnets = [
{
name: 'api'
subnetPrefix: '10.144.0.0/24'
}
{
name: 'worker'
subnetPrefix: '10.144.1.0/24'
}
]
resource VNET 'Microsoft.Network/virtualNetworks@2021-02-01' = {
name: 'vnet1'
location: resourceGroup().location
properties: {
addressSpace: {
addressPrefixes: addressSpace
}
}
}
@batchSize(1)
resource Subnets 'Microsoft.Network/virtualNetworks/subnets@2020-11-01' = [for (sn, index) in subnets: {
name: sn.name
parent: VNET
properties: {
addressPrefix: sn.subnetPrefix
}
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment