Skip to content

[Bug Report]: VPN-Gateway module requires connection property to retain deployed connections #4312

Closed

Description

Describe the bug

Similar to modules such as Virtual Network, Route Table & Network Security Group, the VPN Gateway resource requires the specification of the Connection property upon each deployment as opposed to just use the corresponding child resource.

As the property is currently not provided, this leads to the fact that the module deletes all connections as part of the resource deployment, before recreating them as part of the child deployment.

To solve this, we need to do the same that we did with simiar cases and pass the parameter to the property itself in addition to the child. This way, the connections are retained and simply updated by the child resource deployment.

To reproduce

Deploy the module with with connections twice. You will notice that for a short period (i.e. right after the main resource deployment happens) all connections are gone before being recreated by the vpn-connections child resource deployment.

Code snippet

ARM Reference: https://learn.microsoft.com/en-us/azure/templates/microsoft.network/vpngateways?pivots=deployment-language-bicep#vpngatewayproperties

resource vpnGateway 'Microsoft.Network/vpnGateways@2023-04-01' = {
name: name
location: location
tags: tags
properties: {
bgpSettings: bgpSettings
enableBgpRouteTranslationForNat: enableBgpRouteTranslationForNat
isRoutingPreferenceInternet: isRoutingPreferenceInternet
vpnGatewayScaleUnit: vpnGatewayScaleUnit
virtualHub: {
id: virtualHubResourceId
}
}
}

module vpnGateway_vpnConnections 'vpn-connection/main.bicep' = [for (connection, index) in vpnConnections: {
name: '${deployment().name}-Connection-${index}'
params: {
name: connection.name
vpnGatewayName: vpnGateway.name
connectionBandwidth: contains(connection, 'connectionBandwidth') ? connection.connectionBandwidth : 10
enableBgp: contains(connection, 'enableBgp') ? connection.enableBgp : false
enableInternetSecurity: contains(connection, 'enableInternetSecurity') ? connection.enableInternetSecurity : false
remoteVpnSiteResourceId: contains(connection, 'remoteVpnSiteResourceId') ? connection.remoteVpnSiteResourceId : ''
enableRateLimiting: contains(connection, 'enableRateLimiting') ? connection.enableRateLimiting : false
routingConfiguration: contains(connection, 'routingConfiguration') ? connection.routingConfiguration : {}
routingWeight: contains(connection, 'routingWeight') ? connection.routingWeight : 0
sharedKey: contains(connection, 'sharedKey') ? connection.sharedKey : ''
useLocalAzureIpAddress: contains(connection, 'useLocalAzureIpAddress') ? connection.useLocalAzureIpAddress : false
usePolicyBasedTrafficSelectors: contains(connection, 'usePolicyBasedTrafficSelectors') ? connection.usePolicyBasedTrafficSelectors : false
vpnConnectionProtocolType: contains(connection, 'vpnConnectionProtocolType') ? connection.vpnConnectionProtocolType : 'IKEv2'
enableDefaultTelemetry: enableReferencedModulesTelemetry
ipsecPolicies: contains(connection, 'ipsecPolicies') ? connection.ipsecPolicies : []
trafficSelectorPolicies: contains(connection, 'trafficSelectorPolicies') ? connection.trafficSelectorPolicies : []
vpnLinkConnections: contains(connection, 'vpnLinkConnections') ? connection.vpnLinkConnections : []
}
}]

Relevant log output

No response

Activity

  1. moved this from Needs triage to High priority in Bug boardon Nov 30, 2023
  2. AlexanderSehr commented on Nov 30, 2023

    @AlexanderSehr
    ContributorAuthor

    I will try to fix this as fast as possible, maybe tonight but definitely this week.

  3. moved this from High priority to Closed in Bug boardon Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

[cat] modulesbug

Type

No type

Projects

  • Status
    Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions