Skip to content

Commit

Permalink
feat: Adding Feature 2427 virtual hub routing intent (Azure#3040)
Browse files Browse the repository at this point in the history
## Description

<!--
>Thank you for your contribution !
> Please include a summary of the change and which issue is fixed.
> Please also include the context.
> List any dependencies that are required for this change.
-->

Adding support for configuring Routing Intent within a Virtual Hub. Due
to limitations within the Virtual Hub API, if a pattern is enabling
Routing Intent, the pattern _must_ create invoke this resource twice;
the first invocation creates the Virtual Hub, then the second idempotent
invocation updates the Virtual Hub with the Routing Intent
configuration:

1. Invoke Virtual Hub resource (output hub resource ID)
2. Invoke Firewall resource (pass in hub resource ID)
3. Invoke Virtual Hub resource again (pass in Routing Intent
configuration)

Input parameters for the Routing Intent configuration are:
_privateToFirewall bool
internetToFirewall bool_

Closes
[2427](Azure#2427)

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->


[![avm.res.network.virtual-hub](https://github.com/ericscheffler/bicep-registry-modules/actions/workflows/avm.res.network.virtual-hub.yml/badge.svg?branch=Feature2427-VirtualHub_RoutingIntent)](https://github.com/ericscheffler/bicep-registry-modules/actions/workflows/avm.res.network.virtual-hub.yml)

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [X] Azure Verified Module updates:
- [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [X] Update to documentation

## Checklist

- [X] I'm sure there are no other open Pull Requests for the same
update/change
- [X] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [X] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Co-authored-by: erschef_microsoft <[email protected]>
Co-authored-by: arnoldna <[email protected]>
  • Loading branch information
3 people authored Aug 13, 2024
1 parent 4a59f7c commit 0451dba
Show file tree
Hide file tree
Showing 12 changed files with 686 additions and 23 deletions.
147 changes: 144 additions & 3 deletions avm/res/network/virtual-hub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ If you are planning to deploy a Secure Virtual Hub (with an Azure Firewall integ
- [Parameters](#Parameters)
- [Outputs](#Outputs)
- [Cross-referenced modules](#Cross-referenced-modules)
- [Notes](#Notes)
- [Data Collection](#Data-Collection)

## Resource Types
Expand All @@ -19,7 +20,8 @@ If you are planning to deploy a Secure Virtual Hub (with an Azure Firewall integ
| `Microsoft.Authorization/locks` | [2020-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) |
| `Microsoft.Network/virtualHubs` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-11-01/virtualHubs) |
| `Microsoft.Network/virtualHubs/hubRouteTables` | [2022-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2022-11-01/virtualHubs/hubRouteTables) |
| `Microsoft.Network/virtualHubs/hubVirtualNetworkConnections` | [2022-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2022-11-01/virtualHubs/hubVirtualNetworkConnections) |
| `Microsoft.Network/virtualHubs/hubVirtualNetworkConnections` | [2024-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/virtualHubs/hubVirtualNetworkConnections) |
| `Microsoft.Network/virtualHubs/routingIntent` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-11-01/virtualHubs/routingIntent) |

## Usage examples

Expand All @@ -31,7 +33,8 @@ The following section provides usage examples for the module, which were used to
- [Using only defaults](#example-1-using-only-defaults)
- [Using large parameter set](#example-2-using-large-parameter-set)
- [WAF-aligned](#example-3-waf-aligned)
- [Using Routing Intent](#example-3-using-routing-intent)
- [WAF-aligned](#example-4-waf-aligned)

### Example 1: _Using only defaults_

Expand Down Expand Up @@ -223,7 +226,121 @@ module virtualHub 'br/public:avm/res/network/virtual-hub:<version>' = {
</details>
<p>

### Example 3: _WAF-aligned_
### Example 3: _Using Routing Intent_

This instance deploys the module the Virtual WAN hub with Routing Intent enabled; requires an existing Virtual Hub, as well the firewall Resource ID.


<details>

<summary>via Bicep module</summary>

```bicep
module virtualHub 'br/public:avm/res/network/virtual-hub:<version>' = {
name: 'virtualHubDeployment'
params: {
// Required parameters
addressPrefix: '10.10.0.0/23'
name: 'nvhrtint'
virtualWanId: '<virtualWanId>'
// Non-required parameters
azureFirewallResourceId: '<azureFirewallResourceId>'
hubRouteTables: []
hubRoutingPreference: 'ASPath'
hubVirtualNetworkConnections: [
{
name: 'connection1'
remoteVirtualNetworkId: '<remoteVirtualNetworkId>'
routingConfiguration: {}
}
]
internetToFirewall: false
location: '<location>'
lock: {
kind: 'CanNotDelete'
name: 'myCustomLockName'
}
privateToFirewall: true
tags: {
Environment: 'Non-Prod'
'hidden-title': 'This is visible in the resource name'
Role: 'DeploymentValidation'
}
}
}
```

</details>
<p>

<details>

<summary>via JSON Parameter file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
// Required parameters
"addressPrefix": {
"value": "10.10.0.0/23"
},
"name": {
"value": "nvhrtint"
},
"virtualWanId": {
"value": "<virtualWanId>"
},
// Non-required parameters
"azureFirewallResourceId": {
"value": "<azureFirewallResourceId>"
},
"hubRouteTables": {
"value": []
},
"hubRoutingPreference": {
"value": "ASPath"
},
"hubVirtualNetworkConnections": {
"value": [
{
"name": "connection1",
"remoteVirtualNetworkId": "<remoteVirtualNetworkId>",
"routingConfiguration": {}
}
]
},
"internetToFirewall": {
"value": false
},
"location": {
"value": "<location>"
},
"lock": {
"value": {
"kind": "CanNotDelete",
"name": "myCustomLockName"
}
},
"privateToFirewall": {
"value": true
},
"tags": {
"value": {
"Environment": "Non-Prod",
"hidden-title": "This is visible in the resource name",
"Role": "DeploymentValidation"
}
}
}
}
```

</details>
<p>

### Example 4: _WAF-aligned_

This instance deploys the module in alignment with the best-practices of the Azure Well-Architected Framework.

Expand Down Expand Up @@ -379,10 +496,12 @@ module virtualHub 'br/public:avm/res/network/virtual-hub:<version>' = {
| [`hubRouteTables`](#parameter-hubroutetables) | array | Route tables to create for the virtual hub. |
| [`hubRoutingPreference`](#parameter-hubroutingpreference) | string | The preferred routing preference for this virtual hub. |
| [`hubVirtualNetworkConnections`](#parameter-hubvirtualnetworkconnections) | array | Virtual network connections to create for the virtual hub. |
| [`internetToFirewall`](#parameter-internettofirewall) | bool | Configures Routing Intent to forward Internet traffic (0.0.0.0/0) to Azure Firewall. Default is true. |
| [`location`](#parameter-location) | string | Location for all resources. |
| [`lock`](#parameter-lock) | object | The lock settings of the service. |
| [`p2SVpnGatewayId`](#parameter-p2svpngatewayid) | string | Resource ID of the Point-to-Site VPN Gateway to link to. |
| [`preferredRoutingGateway`](#parameter-preferredroutinggateway) | string | The preferred routing gateway types. |
| [`privateToFirewall`](#parameter-privatetofirewall) | bool | Configures Routing Intent to forward Private traffic (RFC 1918) to Azure Firewall. Default is true. |
| [`routeTableRoutes`](#parameter-routetableroutes) | array | VirtualHub route tables. |
| [`securityPartnerProviderId`](#parameter-securitypartnerproviderid) | string | ID of the Security Partner Provider to link to. |
| [`securityProviderName`](#parameter-securityprovidername) | string | The Security Provider name. |
Expand Down Expand Up @@ -479,6 +598,14 @@ Virtual network connections to create for the virtual hub.
- Type: array
- Default: `[]`

### Parameter: `internetToFirewall`

Configures Routing Intent to forward Internet traffic (0.0.0.0/0) to Azure Firewall. Default is true.

- Required: No
- Type: bool
- Default: `True`

### Parameter: `location`

Location for all resources.
Expand Down Expand Up @@ -548,6 +675,14 @@ The preferred routing gateway types.
]
```

### Parameter: `privateToFirewall`

Configures Routing Intent to forward Private traffic (RFC 1918) to Azure Firewall. Default is true.

- Required: No
- Type: bool
- Default: `True`

### Parameter: `routeTableRoutes`

VirtualHub route tables.
Expand Down Expand Up @@ -639,6 +774,12 @@ Resource ID of the VPN Gateway to link to.

_None_

## Notes

**Configuring Routing Intent**

Due to limitations with the virtual hub resource provider, to fully enable routing intent this resource will need to be invoked twice within the virtual WAN pattern. The first invocation will create the Virtual Hub, after which the resource creating the firewall can be called; then the second invocation can configure routing intent. This ensures that the resources are created in the correct order, and that the required resource ID parameters are available when they are needed.

## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the [repository](https://aka.ms/avm/telemetry). There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
4 changes: 2 additions & 2 deletions avm/res/network/virtual-hub/hub-route-table/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "7178717349327479453"
"version": "0.29.47.4906",
"templateHash": "2767725465951482406"
},
"name": "Virtual Hub Route Tables",
"description": "This module deploys a Virtual Hub Route Table.",
Expand Down
84 changes: 84 additions & 0 deletions avm/res/network/virtual-hub/hub-routing-intent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Virtual Hub Routing Intent `[Microsoft.Network/virtualHubs]`

This module configures Routing Intent for a Virtual Hub; this module requires an existing Virtual Hub, as well the firewall Resource ID.

## Navigation

- [Resource Types](#Resource-Types)
- [Parameters](#Parameters)
- [Outputs](#Outputs)
- [Cross-referenced modules](#Cross-referenced-modules)
- [Notes](#Notes)
- [Data Collection](#Data-Collection)

## Resource Types

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.Network/virtualHubs/routingIntent` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-11-01/virtualHubs/routingIntent) |

## Parameters

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`azureFirewallResourceId`](#parameter-azurefirewallresourceid) | string | Hub firewall Resource ID. |
| [`internetToFirewall`](#parameter-internettofirewall) | bool | Configures Routing Intent to Forward Internet traffic to the firewall (0.0.0.0/0). |
| [`privateToFirewall`](#parameter-privatetofirewall) | bool | Configures Routing Intent to forward Private traffic to the firewall (RFC1918). |
| [`virtualHubName`](#parameter-virtualhubname) | string | Name of the Virtual Hub. |

### Parameter: `azureFirewallResourceId`

Hub firewall Resource ID.

- Required: Yes
- Type: string

### Parameter: `internetToFirewall`

Configures Routing Intent to Forward Internet traffic to the firewall (0.0.0.0/0).

- Required: Yes
- Type: bool

### Parameter: `privateToFirewall`

Configures Routing Intent to forward Private traffic to the firewall (RFC1918).

- Required: Yes
- Type: bool

### Parameter: `virtualHubName`

Name of the Virtual Hub.

- Required: Yes
- Type: string


## Outputs

| Output | Type | Description |
| :-- | :-- | :-- |
| `name` | string | The name of the Routing Intent configuration. |
| `resourceGroupName` | string | The resource group the Routing Intent configuration was deployed into. |
| `resourceId` | string | The resource ID of the Routing Intent configuration. |

## Cross-referenced modules

_None_

## Notes

The use of Routing Intent in a Virtual Hub requires the hub be made 'secure' by associating a firewall (to serve as the next-hop for the routing policy).

The 'azureFirewall' parameter in Microsoft.Network/virtualHubs is *read-only*; in order to properly deploy a Virtual Hub using Routing Intent, the hub's Resource ID must first be passed to the firewall in order for it to be properly associated. In order for this resource to work properly, the resources need to be created in the following order:

- **Virtual Hub**: Suggest minimal hub configuration; name/location/addressPrefix/virtualWan.id
- **Firewall**: Including Virtual Hub Resource ID in the firewall configuration
- **Virtual Hub**: Including all remaining parameters + Routing Intent

## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the [repository](https://aka.ms/avm/telemetry). There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
68 changes: 68 additions & 0 deletions avm/res/network/virtual-hub/hub-routing-intent/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
metadata name = 'Virtual Hub Routing Intent'
metadata description = 'This module configures Routing Intent for a Virtual Hub; this module requires an existing Virtual Hub, as well the firewall Resource ID.'
metadata owner = 'Azure/module-maintainers'

@description('Required. Hub firewall Resource ID.')
param azureFirewallResourceId string

@description('Required. Name of the Virtual Hub.')
param virtualHubName string

@description('Required. Configures Routing Intent to forward Private traffic to the firewall (RFC1918).')
param privateToFirewall bool

@description('Required. Configures Routing Intent to Forward Internet traffic to the firewall (0.0.0.0/0).')
param internetToFirewall bool

resource virtualHub 'Microsoft.Network/virtualHubs@2022-11-01' existing = {
name: virtualHubName
}

resource routingIntent 'Microsoft.Network/virtualHubs/routingIntent@2023-11-01' = {
name: 'defaultRouteTable'
parent : virtualHub
properties: {
routingPolicies: (internetToFirewall == true && privateToFirewall == true) ? [
{
name: '_policy_PublicTraffic'
destinations: [
'Internet'
]
nextHop: azureFirewallResourceId
}
{
name: '_policy_PrivateTraffic'
destinations: [
'PrivateTraffic'
]
nextHop: azureFirewallResourceId
}
] : (internetToFirewall == true && privateToFirewall == false) ? [
{
name: '_policy_PublicTraffic'
destinations: [
'Internet'
]
nextHop: azureFirewallResourceId
}
] : (internetToFirewall == false && privateToFirewall == true) ? [
{
name: '_policy_PrivateTraffic'
destinations: [
'PrivateTraffic'
]
nextHop: azureFirewallResourceId
}
]
: null
}
}

@description('The name of the Routing Intent configuration.')
output name string = routingIntent.name

@description('The resource ID of the Routing Intent configuration.')
output resourceId string = routingIntent.id

@description('The resource group the Routing Intent configuration was deployed into.')
output resourceGroupName string = resourceGroup().name
Loading

0 comments on commit 0451dba

Please sign in to comment.