Skip to content
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

feat: module avm/res/network/virtual-network-gateway #3639

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions avm/res/network/virtual-network-gateway/README.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note, the main.json templates must be re-build with the latest Bicep version 0.31.34 as this version (running on the agents) renders a different main.json file then previous versions.

The steps to execute would be

  • Upgrade your Bicep CLI version to 0.31.34 (e.g. via choco upgrade bicep if choco is used)
  • Re-run the Set-AVMModule script on your module. E.g. via Set-AVMModule -ModuleFolderPath '.\avm\res\automation\automation-account\' -SkipFileAndFolderSetup -SkipReadMe -Recurse
  • Push the changes
  • Re-run the tests to ensure everything works.

If the static tests continue to fail for you, please note that there is currently presumably another new bug which affects some of our modules (ref).

Original file line number Diff line number Diff line change
Expand Up @@ -3179,10 +3179,18 @@ Specifies the VPN type.
| Output | Type | Description |
| :-- | :-- | :-- |
| `activeActive` | bool | Shows if the virtual network gateway is configured in Active-Active mode. |
| `asn` | int | The ASN (Autonomous System Number) of the virtual network gateway. |
| `customBgpIpAddresses` | string | The custom Azure APIPA BGP IP address. |
| `defaultBgpIpAddresses` | string | The default Azure BGP peer IP address. |
| `ipConfigurations` | array | The IPconfigurations object of the Virtual Network Gateway. |
| `location` | string | The location the resource was deployed into. |
| `name` | string | The name of the virtual network gateway. |
| `publicIpAddress` | string | The public IP address of the virtual network gateway. |
| `resourceGroupName` | string | The resource group the virtual network gateway was deployed. |
| `resourceId` | string | The resource ID of the virtual network gateway. |
| `secondBgpIpAddress` | string | The second default Azure BGP peer IP address (Active-Active mode). |
| `secondCustomBgpIpAddress` | string | The second custom Azure APIPA BGP IP address (Active-Active mode). |
| `secondPublicIpAddress` | string | The second public IP address of the virtual network gateway (Active-Active mode). |

## Cross-referenced modules

Expand Down
25 changes: 25 additions & 0 deletions avm/res/network/virtual-network-gateway/main.bicep
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads up as I noticed your test pipeline failed.
A new test is checking weather Required parameters have a default value. In that case it fails, since if a parameter has a default value is Optional by definition.
This is the case for the skuName parameter.
Changing the description to Optional should fix the issue

Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,31 @@ output activeActive bool = virtualNetworkGateway.properties.activeActive
@description('The location the resource was deployed into.')
output location string = virtualNetworkGateway.location

@description('The ASN (Autonomous System Number) of the virtual network gateway.')
output asn int? = virtualNetworkGateway.properties.bgpSettings.asn

@description('The IPconfigurations object of the Virtual Network Gateway.')
output ipConfigurations array? = virtualNetworkGateway.properties.ipConfigurations

@description('The public IP address of the virtual network gateway.')
output publicIpAddress string = !empty(existingFirstPipResourceId) ? reference(existingFirstPipResourceId,'2023-04-01').ipAddress: publicIPAddress[0].outputs.ipAddress
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't this be retrieved as a virtualNetworkGateway property? No matter if existing or not before the deployment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in this case we could provide primary and secondary pip as part of a publicIp output object


@description('The default Azure BGP peer IP address.')
output defaultBgpIpAddresses string? = isBgp ? join(virtualNetworkGateway.properties.bgpSettings.bgpPeeringAddresses[0].defaultBgpIpAddresses, ','): null //'Not applicable (No Bgp)'

@description('The custom Azure APIPA BGP IP address.')
output customBgpIpAddresses string? = isBgp ? join(virtualNetworkGateway.properties.bgpSettings.bgpPeeringAddresses[0].customBgpIpAddresses, ','): null //'Not applicable (No Bgp)'

@description('The second public IP address of the virtual network gateway (Active-Active mode).')
output secondPublicIpAddress string? = isActiveActive ? !empty(existingSecondPipResourceIdVar) ? reference(existingSecondPipResourceIdVar,'2023-04-01').ipAddress: publicIPAddress[1].outputs.ipAddress: null // 'Not applicable (Active-Passive mode)'

@description('The second default Azure BGP peer IP address (Active-Active mode).')
output secondBgpIpAddress string? = isActiveActive && isBgp ? join(virtualNetworkGateway.properties.bgpSettings.bgpPeeringAddresses[1].defaultBgpIpAddresses, ','): null //'Not applicable (Active-Passive mode)'

@description('The second custom Azure APIPA BGP IP address (Active-Active mode).')
output secondCustomBgpIpAddress string? = isActiveActive && isBgp ? join(virtualNetworkGateway.properties.bgpSettings.bgpPeeringAddresses[1].customBgpIpAddresses, ','): null //'Not applicable (Active-Passive mode)'


// =============== //
// Definitions //
// =============== //
Expand Down
65 changes: 64 additions & 1 deletion avm/res/network/virtual-network-gateway/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.30.23.60470",
"templateHash": "1499507825797406827"
"templateHash": "13981694724189921501"
},
"name": "Virtual Network Gateways",
"description": "This module deploys a Virtual Network Gateway.",
Expand Down Expand Up @@ -1627,6 +1627,69 @@
"description": "The location the resource was deployed into."
},
"value": "[reference('virtualNetworkGateway', '2023-04-01', 'full').location]"
},
"asn": {
"type": "int",
"nullable": true,
"metadata": {
"description": "The ASN (Autonomous System Number) of the virtual network gateway."
},
"value": "[reference('virtualNetworkGateway').bgpSettings.asn]"
},
"ipConfigurations": {
"type": "array",
"nullable": true,
"metadata": {
"description": "The IPconfigurations object of the Virtual Network Gateway."
},
"value": "[reference('virtualNetworkGateway').ipConfigurations]"
},
"publicIpAddress": {
"type": "string",
"metadata": {
"description": "The public IP address of the virtual network gateway."
},
"value": "[if(not(empty(parameters('existingFirstPipResourceId'))), reference(parameters('existingFirstPipResourceId'), '2023-04-01').ipAddress, reference(format('publicIPAddress[{0}]', 0)).outputs.ipAddress.value)]"
},
"defaultBgpIpAddresses": {
"type": "string",
"nullable": true,
"metadata": {
"description": "The default Azure BGP peer IP address."
},
"value": "[if(variables('isBgp'), join(reference('virtualNetworkGateway').bgpSettings.bgpPeeringAddresses[0].defaultBgpIpAddresses, ','), null())]"
},
"customBgpIpAddresses": {
"type": "string",
"nullable": true,
"metadata": {
"description": "The custom Azure APIPA BGP IP address."
},
"value": "[if(variables('isBgp'), join(reference('virtualNetworkGateway').bgpSettings.bgpPeeringAddresses[0].customBgpIpAddresses, ','), null())]"
},
"secondPublicIpAddress": {
"type": "string",
"nullable": true,
"metadata": {
"description": "The second public IP address of the virtual network gateway (Active-Active mode)."
},
"value": "[if(variables('isActiveActive'), if(not(empty(variables('existingSecondPipResourceIdVar'))), reference(variables('existingSecondPipResourceIdVar'), '2023-04-01').ipAddress, reference(format('publicIPAddress[{0}]', 1)).outputs.ipAddress.value), null())]"
},
"secondBgpIpAddress": {
"type": "string",
"nullable": true,
"metadata": {
"description": "The second default Azure BGP peer IP address (Active-Active mode)."
},
"value": "[if(and(variables('isActiveActive'), variables('isBgp')), join(reference('virtualNetworkGateway').bgpSettings.bgpPeeringAddresses[1].defaultBgpIpAddresses, ','), null())]"
},
"secondCustomBgpIpAddress": {
"type": "string",
"nullable": true,
"metadata": {
"description": "The second custom Azure APIPA BGP IP address (Active-Active mode)."
},
"value": "[if(and(variables('isActiveActive'), variables('isBgp')), join(reference('virtualNetworkGateway').bgpSettings.bgpPeeringAddresses[1].customBgpIpAddresses, ','), null())]"
}
}
}