Azure / Azure/bicep

Linter rule: Prefer specifying subnets under as child resources rather than network properties.subnets

Open
#4,595 3 comments 0 reactions 0 assignees View on GitHub
devdiv enhancement story: linter rules
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 4h
Merged PRs (30d)
81

Description

See also https://github.com/Azure/bicep/issues/3886

Example:

GOOD:
https://github.com/Azure/bicep/blob/cb2fb8d223862260cfe8bfdc5899477deca3ff7f/docs/examples/101/vnet-two-subnets/main.bicep#L23

```bicep
resource vnet 'Microsoft.Network/virtualNetworks@2020-06-01' = {
name: vnetName
location: resourceGroup().location
properties: {
addressSpace: {
addressPrefixes: [
addressPrefix
]
}
subnets: [
{
name: 'subnet001'
properties: {
addressPrefix: '10.0.0.0/24'
}
}
{
name: 'subnet002'
properties: {
addressPrefix: '10.0.1.0/24'
}
}
]
}
}
```
BAD:
https://github.com/Azure/azure-quickstart-templates/blob/0fc9fbd4407bbb1f58148bdc7247aa095c16b39a/quickstarts/microsoft.network/vnet-two-subnets/main.bicep#L33
```bicep
resource vnet 'Microsoft.Network/virtualNetworks@2020-06-01' = {
name: vnetName
location: location
properties: {
addressSpace: {
addressPrefixes: [
vnetAddressPrefix
]
}
}

resource subnet1 'subnets' = {
name: subnet1Name
properties: {
addressPrefix: subnet1Prefix
}
}

resource subnet2 'subnets' = {
name: subnet2Name
dependsOn: [
subnet1
]
properties: {
addressPrefix: subnet2Prefix
}
}
}
```

Contributor guide

Open the contributing guide

Research direction

Review the linked issue 3886 and the referenced docs/examples/101/vnet-two-subnets/main.bicep and quickstarts/microsoft.network/vnet-two-subnets/main.bicep examples. Determine where Bicep linter rules are defined and tested; done means the rule prefers subnet child resources over network properties.subnets while recognizing the shown good pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.