-
Notifications
You must be signed in to change notification settings - Fork 514
fix: AVM-RES: Update ipamPoolPrefixAllocations type in virtual-network module #6224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Added new type `ipamPoolPrefixAllocationsType` for IPAM pool prefix allocations. - Updated `subnetType` to use the new `ipamPoolPrefixAllocationsType` instead of the previous inline definition. - fixed issue with bicep-docs that failed due to the way ipamPoolPrefixAllocationsType was defined
|
Hey @mikebijl, Most importantly, add a pipeline badge that shows the static & deployment tests passing for the changes? In this case they'd definitely fail the static ones, but may pass the deployment tests. To get the static tests sorted, please run the |
| remotePeeringUseRemoteGateways: bool? | ||
| } | ||
|
|
||
| type ipamPoolPrefixAllocationsType = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few thoughts from my end, considering the AVM specs:
- I'd suggest to move this type into the
subnetchild-module, use it there and import it here. This allows you to use it in both places - The 'id' definition should either be changed to
poolResourceId, or remain an object but be renamed toresourceId. In AVM we strongly advice against usingidonly as it can conflict with other resources that useidfor entirely different meanings. In either case, the subnet module would need to then pass the value on to theidproperty of the resource type implementation - The
numberOfIpAddressesshould, for a similar spec, be declared as a integer, and where it is used be translated to a string. This is simply adviced as strings a way more error prone than integers.
Example (in the subnet module)
Option 1
@description('Conditional. The address space for the subnet, deployed from IPAM Pool. Required if `addressPrefixes` and `addressPrefix` is empty.')
param ipamPoolPrefixAllocations ipamPoolPrefixAllocationsType[]?
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2024-05-01' = {
name: name
parent: virtualNetwork
properties: {
ipamPoolPrefixAllocations: map(ipamPoolPrefixAllocations ?? [], allocation => {
pool: {
id: allocation.pool.resourceId
}
numberOfIpAddresses: string(allocation.numberOfIpAddresses)
})
(...)
}
(...)
@export()
@description('The type of an IPAM-Pool prefix allocation.')
type ipamPoolPrefixAllocationsType = {
@description('Required. The IPAM pool.')
pool: {
@description('Required. The Resource ID of the IPAM pool.')
resourceId: string
}
@description('Required. Number of IP addresses allocated from the pool.')
numberOfIpAddresses: int
}Usage:
subnets: {
name: 'subnet-1'
ipamPoolPrefixAllocations: [
{
pool: {
resourceId: nestedDependencies.outputs.networkManagerIpamPoolId
}
numberOfIpAddresses: 16
}
{
pool: {
resourceId: nestedDependencies.outputs.networkManagerIpamPoolId
}
numberOfIpAddresses: 8
}
]
}Option 2
@description('Conditional. The address space for the subnet, deployed from IPAM Pool. Required if `addressPrefixes` and `addressPrefix` is empty.')
param ipamPoolPrefixAllocations ipamPoolPrefixAllocationsType[]?
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2024-05-01' = {
name: name
parent: virtualNetwork
properties: {
ipamPoolPrefixAllocations: map(ipamPoolPrefixAllocations ?? [], allocation => {
pool: {
id: allocation.poolResourceId
}
numberOfIpAddresses: string(allocation.numberOfIpAddresses)
})
(...)
}
(...)
@export()
@description('The type of an IPAM-Pool prefix allocation.')
type ipamPoolPrefixAllocationsType = {
@description('Required. The IPAM pool resource Id.')
poolResourceId: string
@description('Required. Number of IP addresses allocated from the pool.')
numberOfIpAddresses: int
}Usage:
subnets: {
name: 'subnet-1'
ipamPoolPrefixAllocations: [
{
poolResourceId: nestedDependencies.outputs.networkManagerIpamPoolId
numberOfIpAddresses: 16
}
{
poolResourceId: nestedDependencies.outputs.networkManagerIpamPoolId
numberOfIpAddresses: 8
}
]
}
ipamPoolPrefixAllocationsTypefor IPAM pool prefix allocations.subnetTypeto use the newipamPoolPrefixAllocationsTypeinstead of the previous inline definition.Description
Pipeline Reference
Type of Change
version.json:version.json.version.json.Checklist
Set-AVMModulelocally to generate the supporting module files.