Skip to content

Commit

Permalink
feat: Expand usage of UDT for the AVNM Bicep Module - `avm/res/networ…
Browse files Browse the repository at this point in the history
…k/network-manager` (#1584)

## Description

Introducing User Defined Types for the Azure Virtual Network Manager
(AVNM) Bicep module. Additionally, expanded on the test cases for the
maxium to increase test coverage for UDT validations.

## Pipeline Reference

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

| Pipeline |
| -------- |
|
[![avm.res.network.network-manager](https://github.com/ahmadabdalla/bicep-registry-modules/actions/workflows/avm.res.network.network-manager.yml/badge.svg?branch=users%2Fahmad%2FAVNM_updates)](https://github.com/ahmadabdalla/bicep-registry-modules/actions/workflows/avm.res.network.network-manager.yml)
|

## Type of Change

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

- [ ] Update to CI Environment or utlities (Non-module effecting
changes)
- [ ] 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.
- [x] 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`.
  - [ ] 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 day with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Co-authored-by: Alexander Sehr <[email protected]>
  • Loading branch information
ahmadabdalla and AlexanderSehr authored Jun 3, 2024
1 parent 663a836 commit c3f9b32
Show file tree
Hide file tree
Showing 25 changed files with 4,080 additions and 546 deletions.
687 changes: 643 additions & 44 deletions avm/res/network/network-manager/README.md

Large diffs are not rendered by default.

109 changes: 84 additions & 25 deletions avm/res/network/network-manager/connectivity-configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Connectivity configurations define hub-and-spoke or mesh topologies applied to o

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`appliesToGroups`](#parameter-appliestogroups) | array | Network Groups for the configuration. |
| [`appliesToGroups`](#parameter-appliestogroups) | array | Network Groups for the configuration. A connectivity configuration must be associated to at least one network group. |
| [`connectivityTopology`](#parameter-connectivitytopology) | string | Connectivity topology type. "Mesh" IS CURRENTLY A PREVIEW SERVICE/FEATURE, MICROSOFT MAY NOT PROVIDE SUPPORT FOR THIS, PLEASE CHECK THE PRODUCT DOCS FOR CLARIFICATION. |
| [`name`](#parameter-name) | string | The name of the connectivity configuration. |

Expand All @@ -38,17 +38,65 @@ Connectivity configurations define hub-and-spoke or mesh topologies applied to o

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`deleteExistingPeering`](#parameter-deleteexistingpeering) | string | Flag if need to remove current existing peerings. If set to "True", all peerings on virtual networks in selected network groups will be removed and replaced with the peerings defined by this configuration. Optional when connectivityTopology is of type "HubAndSpoke". |
| [`deleteExistingPeering`](#parameter-deleteexistingpeering) | bool | Flag if need to remove current existing peerings. If set to "True", all peerings on virtual networks in selected network groups will be removed and replaced with the peerings defined by this configuration. Optional when connectivityTopology is of type "HubAndSpoke". |
| [`description`](#parameter-description) | string | A description of the connectivity configuration. |
| [`isGlobal`](#parameter-isglobal) | string | Flag if global mesh is supported. By default, mesh connectivity is applied to virtual networks within the same region. If set to "True", a global mesh enables connectivity across regions. |
| [`isGlobal`](#parameter-isglobal) | bool | Flag if global mesh is supported. By default, mesh connectivity is applied to virtual networks within the same region. If set to "True", a global mesh enables connectivity across regions. |

### Parameter: `appliesToGroups`

Network Groups for the configuration.
Network Groups for the configuration. A connectivity configuration must be associated to at least one network group.

- Required: No
- Required: Yes
- Type: array
- Default: `[]`

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`groupConnectivity`](#parameter-appliestogroupsgroupconnectivity) | string | Group connectivity type. |
| [`networkGroupResourceId`](#parameter-appliestogroupsnetworkgroupresourceid) | string | Resource Id of the network group. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`isGlobal`](#parameter-appliestogroupsisglobal) | bool | Flag if global is supported. |
| [`useHubGateway`](#parameter-appliestogroupsusehubgateway) | bool | Flag if use hub gateway. |

### Parameter: `appliesToGroups.groupConnectivity`

Group connectivity type.

- Required: Yes
- Type: string
- Allowed:
```Bicep
[
'DirectlyConnected'
'None'
]
```

### Parameter: `appliesToGroups.networkGroupResourceId`

Resource Id of the network group.

- Required: Yes
- Type: string

### Parameter: `appliesToGroups.isGlobal`

Flag if global is supported.

- Required: No
- Type: bool

### Parameter: `appliesToGroups.useHubGateway`

Flag if use hub gateway.

- Required: No
- Type: bool

### Parameter: `connectivityTopology`

Expand Down Expand Up @@ -77,52 +125,63 @@ List of hub items. This will create peerings between the specified hub and the v

- Required: No
- Type: array
- Default: `[]`

### Parameter: `networkManagerName`
**Required parameters**

The name of the parent network manager. Required if the template is used in a standalone deployment.
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`resourceId`](#parameter-hubsresourceid) | string | Resource Id of the hub. |
| [`resourceType`](#parameter-hubsresourcetype) | string | Resource type of the hub. |

### Parameter: `hubs.resourceId`

Resource Id of the hub.

- Required: Yes
- Type: string

### Parameter: `deleteExistingPeering`
### Parameter: `hubs.resourceType`

Flag if need to remove current existing peerings. If set to "True", all peerings on virtual networks in selected network groups will be removed and replaced with the peerings defined by this configuration. Optional when connectivityTopology is of type "HubAndSpoke".
Resource type of the hub.

- Required: No
- Required: Yes
- Type: string
- Default: `'False'`
- Allowed:
```Bicep
[
'False'
'True'
'Microsoft.Network/virtualNetworks'
]
```

### Parameter: `networkManagerName`

The name of the parent network manager. Required if the template is used in a standalone deployment.

- Required: Yes
- Type: string

### Parameter: `deleteExistingPeering`

Flag if need to remove current existing peerings. If set to "True", all peerings on virtual networks in selected network groups will be removed and replaced with the peerings defined by this configuration. Optional when connectivityTopology is of type "HubAndSpoke".

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

### Parameter: `description`

A description of the connectivity configuration.

- Required: No
- Type: string
- Default: `''`

### Parameter: `isGlobal`

Flag if global mesh is supported. By default, mesh connectivity is applied to virtual networks within the same region. If set to "True", a global mesh enables connectivity across regions.

- Required: No
- Type: string
- Default: `'False'`
- Allowed:
```Bicep
[
'False'
'True'
]
```
- Type: bool
- Default: `False`


## Outputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ param name string

@maxLength(500)
@sys.description('Optional. A description of the connectivity configuration.')
param description string = ''
param description string?

@sys.description('Required. Network Groups for the configuration.')
param appliesToGroups array = []
@sys.description('Required. Network Groups for the configuration. A connectivity configuration must be associated to at least one network group.')
param appliesToGroups appliesToGroupsType

@allowed([
'HubAndSpoke'
Expand All @@ -25,21 +25,13 @@ param appliesToGroups array = []
param connectivityTopology string

@sys.description('Conditional. List of hub items. This will create peerings between the specified hub and the virtual networks in the network group specified. Required if connectivityTopology is of type "HubAndSpoke".')
param hubs array = []
param hubs hubsType

@allowed([
'True'
'False'
])
@sys.description('Optional. Flag if need to remove current existing peerings. If set to "True", all peerings on virtual networks in selected network groups will be removed and replaced with the peerings defined by this configuration. Optional when connectivityTopology is of type "HubAndSpoke".')
param deleteExistingPeering string = 'False'
param deleteExistingPeering bool = false

@allowed([
'True'
'False'
])
@sys.description('Optional. Flag if global mesh is supported. By default, mesh connectivity is applied to virtual networks within the same region. If set to "True", a global mesh enables connectivity across regions.')
param isGlobal string = 'False'
param isGlobal bool = false

resource networkManager 'Microsoft.Network/networkManagers@2023-04-01' existing = {
name: networkManagerName
Expand All @@ -49,12 +41,17 @@ resource connectivityConfiguration 'Microsoft.Network/networkManagers/connectivi
name: name
parent: networkManager
properties: {
appliesToGroups: appliesToGroups
appliesToGroups: map(appliesToGroups, (group) => {
groupConnectivity: group.groupConnectivity
isGlobal: string(group.isGlobal) ?? 'false'
networkGroupId: any(group.networkGroupResourceId)
useHubGateway: string(group.useHubGateway) ?? 'false'
})
connectivityTopology: connectivityTopology
deleteExistingPeering: connectivityTopology == 'HubAndSpoke' ? deleteExistingPeering : 'False'
description: description
deleteExistingPeering: connectivityTopology == 'HubAndSpoke' ? string(deleteExistingPeering) : 'false'
description: description ?? ''
hubs: connectivityTopology == 'HubAndSpoke' ? hubs : []
isGlobal: isGlobal
isGlobal: string(isGlobal)
}
}

Expand All @@ -66,3 +63,29 @@ output resourceId string = connectivityConfiguration.id

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

// =============== //
// Definitions //
// =============== //

type appliesToGroupsType = {
@sys.description('Required. Group connectivity type.')
groupConnectivity: ('DirectlyConnected' | 'None')

@sys.description('Optional. Flag if global is supported.')
isGlobal: bool?

@sys.description('Required. Resource Id of the network group.')
networkGroupResourceId: string

@sys.description('Optional. Flag if use hub gateway.')
useHubGateway: bool?
}[]

type hubsType = {
@sys.description('Required. Resource Id of the hub.')
resourceId: string

@sys.description('Required. Resource type of the hub.')
resourceType: 'Microsoft.Network/virtualNetworks'
}[]?
Loading

0 comments on commit c3f9b32

Please sign in to comment.