From 960bd21988f83d4bfb167dcab5951d384360f8f9 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 1 Dec 2023 07:39:36 +0100 Subject: [PATCH] feat: Added routeType type (#677) ## Description Added a new user-defined type called `routeType`. | Pipeline | | - | | [![avm.res.network.route-table](https://github.com/johnlokerse/bicep-registry-modules/actions/workflows/avm.res.network.route-table.yml/badge.svg?branch=update%2Frtr-type&event=workflow_dispatch)](https://github.com/johnlokerse/bicep-registry-modules/actions/workflows/avm.res.network.route-table.yml) | --------- Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- avm/res/network/route-table/README.md | 59 ++++++++++++++++++++-- avm/res/network/route-table/main.bicep | 23 ++++++++- avm/res/network/route-table/main.json | 63 ++++++++++++++++++++++-- avm/res/network/route-table/version.json | 4 +- 4 files changed, 137 insertions(+), 12 deletions(-) diff --git a/avm/res/network/route-table/README.md b/avm/res/network/route-table/README.md index 1c857e3d5e..cfe9c7623e 100644 --- a/avm/res/network/route-table/README.md +++ b/avm/res/network/route-table/README.md @@ -316,7 +316,7 @@ module routeTable 'br/public:avm/res/network/route-table:' = { | [`location`](#parameter-location) | string | Location for all resources. | | [`lock`](#parameter-lock) | object | The lock settings of the service. | | [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalId' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'. | -| [`routes`](#parameter-routes) | array | An Array of Routes to be established within the hub route table. | +| [`routes`](#parameter-routes) | array | An array of routes to be established within the hub route table. | | [`tags`](#parameter-tags) | object | Tags of the resource. | ### Parameter: `disableBgpRoutePropagation` @@ -443,10 +443,63 @@ Required. The name of the role to assign. If it cannot be found you can specify ### Parameter: `routes` -An Array of Routes to be established within the hub route table. +An array of routes to be established within the hub route table. - Required: No - Type: array -- Default: `[]` + + +| Name | Required | Type | Description | +| :-- | :-- | :--| :-- | +| [`name`](#parameter-routesname) | Yes | string | Required. Name of the route. | +| [`properties`](#parameter-routesproperties) | Yes | object | | + +### Parameter: `routes.name` + +Required. Name of the route. + +- Required: Yes +- Type: string + +### Parameter: `routes.properties` +- Required: Yes +- Type: object + +| Name | Required | Type | Description | +| :-- | :-- | :--| :-- | +| [`addressPrefix`](#parameter-routespropertiesaddressprefix) | No | string | Optional. The destination CIDR to which the route applies. | +| [`hasBgpOverride`](#parameter-routespropertieshasbgpoverride) | No | bool | Optional. A value indicating whether this route overrides overlapping BGP routes regardless of LPM. | +| [`nextHopIpAddress`](#parameter-routespropertiesnexthopipaddress) | No | string | Optional. The IP address packets should be forwarded to. Next hop values are only allowed in routes where the next hop type is VirtualAppliance. | +| [`nextHopType`](#parameter-routespropertiesnexthoptype) | Yes | string | Required. The type of Azure hop the packet should be sent to. | + +### Parameter: `routes.properties.addressPrefix` + +Optional. The destination CIDR to which the route applies. + +- Required: No +- Type: string + +### Parameter: `routes.properties.hasBgpOverride` + +Optional. A value indicating whether this route overrides overlapping BGP routes regardless of LPM. + +- Required: No +- Type: bool + +### Parameter: `routes.properties.nextHopIpAddress` + +Optional. The IP address packets should be forwarded to. Next hop values are only allowed in routes where the next hop type is VirtualAppliance. + +- Required: No +- Type: string + +### Parameter: `routes.properties.nextHopType` + +Required. The type of Azure hop the packet should be sent to. + +- Required: Yes +- Type: string +- Allowed: `[Internet, None, VirtualAppliance, VirtualNetworkGateway, VnetLocal]` + ### Parameter: `tags` diff --git a/avm/res/network/route-table/main.bicep b/avm/res/network/route-table/main.bicep index 2c596f557d..54bb6a9a7b 100644 --- a/avm/res/network/route-table/main.bicep +++ b/avm/res/network/route-table/main.bicep @@ -8,8 +8,8 @@ param name string @description('Optional. Location for all resources.') param location string = resourceGroup().location -@description('Optional. An Array of Routes to be established within the hub route table.') -param routes array = [] +@description('Optional. An array of routes to be established within the hub route table.') +param routes routeType @description('Optional. Switch to disable BGP route propagation.') param disableBgpRoutePropagation bool = false @@ -132,3 +132,22 @@ type roleAssignmentType = { @description('Optional. The Resource Id of the delegated managed identity resource.') delegatedManagedIdentityResourceId: string? }[]? + +type routeType = { + @description('Required. Name of the route.') + name: string + + properties: { + @description('Required. The type of Azure hop the packet should be sent to.') + nextHopType: ('VirtualAppliance' | 'VnetLocal' | 'Internet' | 'VirtualNetworkGateway' | 'None') + + @description('Optional. The destination CIDR to which the route applies.') + addressPrefix: string? + + @description('Optional. A value indicating whether this route overrides overlapping BGP routes regardless of LPM.') + hasBgpOverride: bool? + + @description('Optional. The IP address packets should be forwarded to. Next hop values are only allowed in routes where the next hop type is VirtualAppliance.') + nextHopIpAddress: string? + } +}[]? diff --git a/avm/res/network/route-table/main.json b/avm/res/network/route-table/main.json index 8aa492459b..2dd8d1a934 100644 --- a/avm/res/network/route-table/main.json +++ b/avm/res/network/route-table/main.json @@ -5,8 +5,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.23.1.45101", - "templateHash": "6317323502554535880" + "version": "0.21.1.54444", + "templateHash": "12297099865892076814" }, "name": "Route Tables", "description": "This module deploys a User Defined Route Table (UDR).", @@ -103,6 +103,60 @@ } }, "nullable": true + }, + "routeType": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "metadata": { + "description": "Required. Name of the route." + } + }, + "properties": { + "type": "object", + "properties": { + "nextHopType": { + "type": "string", + "allowedValues": [ + "Internet", + "None", + "VirtualAppliance", + "VirtualNetworkGateway", + "VnetLocal" + ], + "metadata": { + "description": "Required. The type of Azure hop the packet should be sent to." + } + }, + "addressPrefix": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The destination CIDR to which the route applies." + } + }, + "hasBgpOverride": { + "type": "bool", + "nullable": true, + "metadata": { + "description": "Optional. A value indicating whether this route overrides overlapping BGP routes regardless of LPM." + } + }, + "nextHopIpAddress": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The IP address packets should be forwarded to. Next hop values are only allowed in routes where the next hop type is VirtualAppliance." + } + } + } + } + } + }, + "nullable": true } }, "parameters": { @@ -120,10 +174,9 @@ } }, "routes": { - "type": "array", - "defaultValue": [], + "$ref": "#/definitions/routeType", "metadata": { - "description": "Optional. An Array of Routes to be established within the hub route table." + "description": "Optional. An array of routes to be established within the hub route table." } }, "disableBgpRoutePropagation": { diff --git a/avm/res/network/route-table/version.json b/avm/res/network/route-table/version.json index 7fa401bdf7..1c035df49f 100644 --- a/avm/res/network/route-table/version.json +++ b/avm/res/network/route-table/version.json @@ -1,7 +1,7 @@ { "$schema": "https://aka.ms/bicep-registry-module-version-file-schema#", - "version": "0.1", + "version": "0.2", "pathFilters": [ "./main.json" ] -} +} \ No newline at end of file