Virtual network module use of contains function #2214
-
Hi! I have a quick question for you, is there a particular reason the It's something that I could submit a fix for, but I want to know if there was a particular reason it was done this way before working on it :) ! Here's an example for what the module prevents us to do:
Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Hey @maxime-roy, thanks for your question.
subnets: [
{
addressPrefix: '10.0.255.0/24'
name: 'GatewaySubnet'
}
{
addressPrefix: '10.0.0.0/24'
name: '<<namePrefix>>-az-subnet-x-001'
networkSecurityGroupId: resourceGroupResources.outputs.networkSecurityGroupResourceId
roleAssignments: [
{
principalIds: [
resourceGroupResources.outputs.managedIdentityPrincipalId
]
roleDefinitionIdOrName: 'Reader'
}
]
routeTableId: resourceGroupResources.outputs.routeTableResourceId
serviceEndpoints: [
{
service: 'Microsoft.Storage'
}
{
service: 'Microsoft.Sql'
}
]
}
] By checking on subnets: [
{
addressPrefix: '10.0.255.0/24'
name: 'GatewaySubnet'
networkSecurityGroupId: ''
roleAssignments: []
routeTableId: ''
serviceEndpoints: []
}
{
addressPrefix: '10.0.0.0/24'
name: '<<namePrefix>>-az-subnet-x-001'
networkSecurityGroupId: resourceGroupResources.outputs.networkSecurityGroupResourceId
roleAssignments: [
{
principalIds: [
resourceGroupResources.outputs.managedIdentityPrincipalId
]
roleDefinitionIdOrName: 'Reader'
}
]
routeTableId: resourceGroupResources.outputs.routeTableResourceId
serviceEndpoints: [
{
service: 'Microsoft.Storage'
}
{
service: 'Microsoft.Sql'
}
]
}
] I wouldn't suggest to get rid of the networkSecurityGroup: contains(subnet, 'networkSecurityGroupId') && !empty(subnet.networkSecurityGroupId) ? {
'id': subnet.networkSecurityGroupId
} : null Nevertheless, I'd be interested in understanding your scenario a bit more. Is there anything that prevents you to simply not specify an empty subnet object parameter instead of providing an empty value for it? |
Beta Was this translation helpful? Give feedback.
-
Thanks @maxime-roy and @coolhome for elaborating. Besides the discussion started as a feature request for the Vnet module, for consistency that would make sense to be implemented for all input parameter objects throughout the library. |
Beta Was this translation helpful? Give feedback.
-
I'd suggest to close this discussion in favor of issue #2268. Otherwise it may become difficult to track the discussion :) |
Beta Was this translation helpful? Give feedback.
Thanks @maxime-roy and @coolhome for elaborating.
I created issue #2268 from this discussion to provide more visibility to the request and allow its triage.
Besides the discussion started as a feature request for the Vnet module, for consistency that would make sense to be implemented for all input parameter objects throughout the library.