Azure / Azure/bicep

Simplify properties that are resource references

Open
#285 14 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

ARM makes extensive use of the format
``` Json
"otherresource": {
"id": "[resourceId(....)]"
}
```
Take for example the network interface in [Bicep Playground 0.0.8](https://bicepdemo.z22.web.core.windows.net/), there is `subnet`, `publicIpAddress`, and `networkSecurityGroup`.

```
resource nic1 'Microsoft.Network/networkInterfaces@2017-06-01' = {
name: nic1Name
location: location
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
properties: {
subnet: {
id: '${vnet.id}/subnets/${subnet1Name}'
}
privateIPAllocationMethod: 'Dynamic'
publicIpAddress: {
id: pip.id
}
}
}
]
networkSecurityGroup: {
id: nsg.id
}
}
}
```

Could this be simplified to:
```
resource nic1 'Microsoft.Network/networkInterfaces@2017-06-01' = {
name: nic1Name
location: location
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
properties: {
subnet: vnet.subnets.subnet1Name
privateIPAllocationMethod: 'Dynamic'
publicIpAddress: pip
}
}
]
networkSecurityGroup: nsg
}
}
```

Bicep should be able to tell that the ARM schema for the resource needs an object of the format `{ "id": "" }` so it can extract this directly from the reference.

Also, the reference to the sub-resource (subnet in this case) could be simple dot notation as every sub-resource will have a name.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.