Skip to content

Commit

Permalink
feat: Improvements of the avm/res/network/public-ip-prefix module (#…
Browse files Browse the repository at this point in the history
…3674)

## Description

Improvements of the `avm/res/network/public-ip-prefix` module:

- adds support for `ipTags`
- adds support for IPv6 prefixes
- add `tier` parameter
- uses common AVM types
- API version update

Fixes #3653 
Fixes #3673 

## Pipeline Reference

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

| Pipeline |
| -------- |
|
[![avm.res.network.public-ip-prefix](https://github.com/krbar/bicep-registry-modules/actions/workflows/avm.res.network.public-ip-prefix.yml/badge.svg?branch=users%2Fkrbar%2FipPrefixIpTags)](https://github.com/krbar/bicep-registry-modules/actions/workflows/avm.res.network.public-ip-prefix.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`:
- [x] 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`.
  - [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 -->
  • Loading branch information
krbar authored Oct 31, 2024
1 parent 1022248 commit 9d38583
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 131 deletions.
170 changes: 163 additions & 7 deletions avm/res/network/public-ip-prefix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This module deploys a Public IP Prefix.
| :-- | :-- |
| `Microsoft.Authorization/locks` | [2020-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) |
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |
| `Microsoft.Network/publicIPPrefixes` | [2023-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-09-01/publicIPPrefixes) |
| `Microsoft.Network/publicIPPrefixes` | [2024-01-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2024-01-01/publicIPPrefixes) |

## Usage examples

Expand All @@ -27,8 +27,9 @@ The following section provides usage examples for the module, which were used to
>**Note**: To reference the module, please use the following syntax `br/public:avm/res/network/public-ip-prefix:<version>`.
- [Using only defaults](#example-1-using-only-defaults)
- [Using large parameter set](#example-2-using-large-parameter-set)
- [WAF-aligned](#example-3-waf-aligned)
- [IPv6 Public IP Prefix](#example-2-ipv6-public-ip-prefix)
- [Using large parameter set](#example-3-using-large-parameter-set)
- [WAF-aligned](#example-4-waf-aligned)

### Example 1: _Using only defaults_

Expand Down Expand Up @@ -99,7 +100,81 @@ param location = '<location>'
</details>
<p>

### Example 2: _Using large parameter set_
### Example 2: _IPv6 Public IP Prefix_

This instance deploys the module using the IPv6 version of the Public IP Prefix.


<details>

<summary>via Bicep module</summary>

```bicep
module publicIpPrefix 'br/public:avm/res/network/public-ip-prefix:<version>' = {
name: 'publicIpPrefixDeployment'
params: {
// Required parameters
name: 'npipip6001'
prefixLength: 127
// Non-required parameters
location: '<location>'
publicIPAddressVersion: 'IPv6'
}
}
```

</details>
<p>

<details>

<summary>via JSON parameters file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
// Required parameters
"name": {
"value": "npipip6001"
},
"prefixLength": {
"value": 127
},
// Non-required parameters
"location": {
"value": "<location>"
},
"publicIPAddressVersion": {
"value": "IPv6"
}
}
}
```

</details>
<p>

<details>

<summary>via Bicep parameters file</summary>

```bicep-params
using 'br/public:avm/res/network/public-ip-prefix:<version>'
// Required parameters
param name = 'npipip6001'
param prefixLength = 127
// Non-required parameters
param location = '<location>'
param publicIPAddressVersion = 'IPv6'
```

</details>
<p>

### Example 3: _Using large parameter set_

This instance deploys the module with most of its features enabled.

Expand All @@ -116,6 +191,12 @@ module publicIpPrefix 'br/public:avm/res/network/public-ip-prefix:<version>' = {
name: 'npipmax001'
prefixLength: 28
// Non-required parameters
ipTags: [
{
ipTagType: 'RoutingPreference'
tag: 'Internet'
}
]
location: '<location>'
lock: {
kind: 'CanNotDelete'
Expand Down Expand Up @@ -173,6 +254,14 @@ module publicIpPrefix 'br/public:avm/res/network/public-ip-prefix:<version>' = {
"value": 28
},
// Non-required parameters
"ipTags": {
"value": [
{
"ipTagType": "RoutingPreference",
"tag": "Internet"
}
]
},
"location": {
"value": "<location>"
},
Expand Down Expand Up @@ -234,6 +323,12 @@ using 'br/public:avm/res/network/public-ip-prefix:<version>'
param name = 'npipmax001'
param prefixLength = 28
// Non-required parameters
param ipTags = [
{
ipTagType: 'RoutingPreference'
tag: 'Internet'
}
]
param location = '<location>'
param lock = {
kind: 'CanNotDelete'
Expand Down Expand Up @@ -272,7 +367,7 @@ param zones = [
</details>
<p>

### Example 3: _WAF-aligned_
### 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 @@ -373,11 +468,14 @@ param tags = {
| :-- | :-- | :-- |
| [`customIPPrefix`](#parameter-customipprefix) | object | The custom IP address prefix that this prefix is associated with. A custom IP address prefix is a contiguous range of IP addresses owned by an external customer and provisioned into a subscription. When a custom IP prefix is in Provisioned, Commissioning, or Commissioned state, a linked public IP prefix can be created. Either as a subset of the custom IP prefix range or the entire range. |
| [`enableTelemetry`](#parameter-enabletelemetry) | bool | Enable/Disable usage telemetry for module. |
| [`ipTags`](#parameter-iptags) | array | The list of tags associated with the public IP prefix. |
| [`location`](#parameter-location) | string | Location for all resources. |
| [`lock`](#parameter-lock) | object | The lock settings of the service. |
| [`publicIPAddressVersion`](#parameter-publicipaddressversion) | string | The public IP address version. |
| [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignments to create. |
| [`tags`](#parameter-tags) | object | Tags of the resource. |
| [`zones`](#parameter-zones) | array | A list of availability zones denoting the IP allocated for the resource needs to come from. |
| [`tier`](#parameter-tier) | string | Tier of a public IP prefix SKU. If set to `Global`, the `zones` property must be empty. |
| [`zones`](#parameter-zones) | array | A list of availability zones denoting the IP allocated for the resource needs to come from. This is only applicable for regional public IP prefixes and must be empty for global public IP prefixes. |

### Parameter: `name`

Expand Down Expand Up @@ -409,6 +507,34 @@ Enable/Disable usage telemetry for module.
- Type: bool
- Default: `True`

### Parameter: `ipTags`

The list of tags associated with the public IP prefix.

- Required: No
- Type: array

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`ipTagType`](#parameter-iptagsiptagtype) | string | The IP tag type. |
| [`tag`](#parameter-iptagstag) | string | The IP tag. |

### Parameter: `ipTags.ipTagType`

The IP tag type.

- Required: Yes
- Type: string

### Parameter: `ipTags.tag`

The IP tag.

- Required: Yes
- Type: string

### Parameter: `location`

Location for all resources.
Expand Down Expand Up @@ -453,6 +579,21 @@ Specify the name of lock.
- Required: No
- Type: string

### Parameter: `publicIPAddressVersion`

The public IP address version.

- Required: No
- Type: string
- Default: `'IPv4'`
- Allowed:
```Bicep
[
'IPv4'
'IPv6'
]
```

### Parameter: `roleAssignments`

Array of role assignments to create.
Expand Down Expand Up @@ -564,9 +705,24 @@ Tags of the resource.
- Required: No
- Type: object

### Parameter: `tier`

Tier of a public IP prefix SKU. If set to `Global`, the `zones` property must be empty.

- Required: No
- Type: string
- Default: `'Regional'`
- Allowed:
```Bicep
[
'Global'
'Regional'
]
```

### Parameter: `zones`

A list of availability zones denoting the IP allocated for the resource needs to come from.
A list of availability zones denoting the IP allocated for the resource needs to come from. This is only applicable for regional public IP prefixes and must be empty for global public IP prefixes.

- Required: No
- Type: array
Expand Down
72 changes: 34 additions & 38 deletions avm/res/network/public-ip-prefix/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,46 @@ metadata owner = 'Azure/module-maintainers'
@minLength(1)
param name string

@description('Optional. Tier of a public IP prefix SKU. If set to `Global`, the `zones` property must be empty.')
@allowed([
'Global'
'Regional'
])
param tier string = 'Regional'

@description('Optional. Location for all resources.')
param location string = resourceGroup().location

@description('Required. Length of the Public IP Prefix.')
@minValue(21)
@maxValue(31)
@maxValue(127)
param prefixLength int

@description('Optional. The public IP address version.')
@allowed([
'IPv4'
'IPv6'
])
param publicIPAddressVersion string = 'IPv4'

import { lockType } from 'br/public:avm/utl/types/avm-common-types:0.2.1'
@description('Optional. The lock settings of the service.')
param lock lockType
param lock lockType?

import { roleAssignmentType } from 'br/public:avm/utl/types/avm-common-types:0.2.1'
@description('Optional. Array of role assignments to create.')
param roleAssignments roleAssignmentType
param roleAssignments roleAssignmentType[]?

@description('Optional. Tags of the resource.')
param tags object?

@description('Optional. The custom IP address prefix that this prefix is associated with. A custom IP address prefix is a contiguous range of IP addresses owned by an external customer and provisioned into a subscription. When a custom IP prefix is in Provisioned, Commissioning, or Commissioned state, a linked public IP prefix can be created. Either as a subset of the custom IP prefix range or the entire range.')
param customIPPrefix object = {}

@description('Optional. A list of availability zones denoting the IP allocated for the resource needs to come from.')
@description('Optional. The list of tags associated with the public IP prefix.')
param ipTags ipTagType[]?

@description('Optional. A list of availability zones denoting the IP allocated for the resource needs to come from. This is only applicable for regional public IP prefixes and must be empty for global public IP prefixes.')
@allowed([
1
2
Expand Down Expand Up @@ -89,18 +108,20 @@ resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableT
}
}

resource publicIpPrefix 'Microsoft.Network/publicIPPrefixes@2023-09-01' = {
resource publicIpPrefix 'Microsoft.Network/publicIPPrefixes@2024-01-01' = {
name: name
location: location
tags: tags
sku: {
name: 'Standard'
tier: tier
}
zones: map(zones, zone => string(zone))
properties: {
customIPPrefix: !empty(customIPPrefix) ? customIPPrefix : null
publicIPAddressVersion: 'IPv4'
publicIPAddressVersion: publicIPAddressVersion
prefixLength: prefixLength
ipTags: ipTags
}
}

Expand Down Expand Up @@ -147,36 +168,11 @@ output location string = publicIpPrefix.location
// Definitions //
// =============== //

type lockType = {
@description('Optional. Specify the name of lock.')
name: string?

@description('Optional. Specify the type of lock.')
kind: ('CanNotDelete' | 'ReadOnly' | 'None')?
}?
@export()
type ipTagType = {
@description('Required. The IP tag type.')
ipTagType: string

type roleAssignmentType = {
@description('Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated.')
name: string?

@description('Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'.')
roleDefinitionIdOrName: string

@description('Required. The principal ID of the principal (user/group/identity) to assign the role to.')
principalId: string

@description('Optional. The principal type of the assigned principal ID.')
principalType: ('ServicePrincipal' | 'Group' | 'User' | 'ForeignGroup' | 'Device')?

@description('Optional. The description of the role assignment.')
description: string?

@description('Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase "foo_storage_container".')
condition: string?

@description('Optional. Version of the condition.')
conditionVersion: '2.0'?

@description('Optional. The Resource Id of the delegated managed identity resource.')
delegatedManagedIdentityResourceId: string?
}[]?
@description('Required. The IP tag.')
tag: string
}
Loading

0 comments on commit 9d38583

Please sign in to comment.