Skip to content

Commit

Permalink
feat: Adding support for multiple custom domains in AFD endpoints + r…
Browse files Browse the repository at this point in the history
…emoving deprecated Akamai SKU for CDN profiles - `avm/res/cdn/profile` (Azure#2014)

## Description

- Adding support for multiple custom domains in AFD endpoint routes
(feature request Azure#1639 )
- Removing deprecated Akamai SKU for CDN profiles
- This is introducing breaking changes therefor creating a new version
0.3

Fixes Azure#1639 
Closes Azure#1639 

## Pipeline Reference


[![avm.res.cdn.profile](https://github.com/gbeaud/bicep-registry-modules/actions/workflows/avm.res.cdn.profile.yml/badge.svg?branch=main)](https://github.com/gbeaud/bicep-registry-modules/actions/workflows/avm.res.cdn.profile.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)
- [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`.
- [X] 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
  • Loading branch information
gbeaud authored and hundredacres committed Jun 19, 2024
1 parent f8de1d2 commit 95f6aa9
Show file tree
Hide file tree
Showing 19 changed files with 159 additions and 124 deletions.
9 changes: 6 additions & 3 deletions avm/res/cdn/profile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ module profile 'br/public:avm/res/cdn/profile:<version>' = {
name: 'dep-test-cdnpafd-afd-endpoint'
routes: [
{
customDomainName: 'dep-test-cdnpafd-custom-domain'
customDomainNames: [
'dep-test-cdnpafd-custom-domain'
]
name: 'dep-test-cdnpafd-afd-route'
originGroupName: 'dep-test-cdnpafd-origin-group'
ruleSets: [
Expand Down Expand Up @@ -154,7 +156,9 @@ module profile 'br/public:avm/res/cdn/profile:<version>' = {
"name": "dep-test-cdnpafd-afd-endpoint",
"routes": [
{
"customDomainName": "dep-test-cdnpafd-custom-domain",
"customDomainNames": [
"dep-test-cdnpafd-custom-domain"
],
"name": "dep-test-cdnpafd-afd-route",
"originGroupName": "dep-test-cdnpafd-origin-group",
"ruleSets": [
Expand Down Expand Up @@ -619,7 +623,6 @@ The pricing tier (defines a CDN provider, feature list and rate) of the CDN prof
'Premium_AzureFrontDoor'
'Premium_Verizon'
'Standard_955BandWidth_ChinaCdn'
'Standard_Akamai'
'Standard_AvgBandWidth_ChinaCdn'
'Standard_AzureFrontDoor'
'Standard_ChinaCdn'
Expand Down
2 changes: 1 addition & 1 deletion avm/res/cdn/profile/afdEndpoint/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module afdEndpoint_routes 'route/main.bicep' = [
profileName: profile.name
afdEndpointName: afdEndpoint.name
cacheConfiguration: route.?cacheConfiguration
customDomainName: route.?customDomainName
customDomainNames: route.?customDomainNames
enabledState: route.?enabledState
forwardingProtocol: route.?forwardingProtocol
httpsRedirect: route.?httpsRedirect
Expand Down
40 changes: 26 additions & 14 deletions avm/res/cdn/profile/afdEndpoint/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "8869132357079269087"
"version": "0.26.170.59819",
"templateHash": "1139997023996590437"
},
"name": "CDN Profiles AFD Endpoints",
"description": "This module deploys a CDN Profile AFD Endpoint.",
Expand Down Expand Up @@ -118,8 +118,8 @@
"cacheConfiguration": {
"value": "[tryGet(coalesce(parameters('routes'), createArray())[copyIndex()], 'cacheConfiguration')]"
},
"customDomainName": {
"value": "[tryGet(coalesce(parameters('routes'), createArray())[copyIndex()], 'customDomainName')]"
"customDomainNames": {
"value": "[tryGet(coalesce(parameters('routes'), createArray())[copyIndex()], 'customDomainNames')]"
},
"enabledState": {
"value": "[tryGet(coalesce(parameters('routes'), createArray())[copyIndex()], 'enabledState')]"
Expand Down Expand Up @@ -156,8 +156,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "8525791914559803218"
"version": "0.26.170.59819",
"templateHash": "5770374289363120600"
},
"name": "CDN Profiles AFD Endpoint Route",
"description": "This module deploys a CDN Profile AFD Endpoint route.",
Expand Down Expand Up @@ -189,11 +189,14 @@
"description": "Optional. The caching configuration for this route. To disable caching, do not provide a cacheConfiguration object."
}
},
"customDomainName": {
"type": "string",
"customDomainNames": {
"type": "array",
"items": {
"type": "string"
},
"nullable": true,
"metadata": {
"description": "Optional. The name of the custom domain. The custom domain must be defined in the profile customDomains."
"description": "Optional. The names of the custom domains. The custom domains must be defined in the profile customDomains array."
}
},
"forwardingProtocol": {
Expand Down Expand Up @@ -290,12 +293,15 @@
"profile"
]
},
"profile::customDomain": {
"condition": "[not(empty(parameters('customDomainName')))]",
"profile::customDomains": {
"copy": {
"name": "customDomains",
"count": "[length(coalesce(parameters('customDomainNames'), createArray()))]"
},
"existing": true,
"type": "Microsoft.Cdn/profiles/customDomains",
"apiVersion": "2023-05-01",
"name": "[format('{0}/{1}', parameters('profileName'), coalesce(parameters('customDomainName'), ''))]",
"name": "[format('{0}/{1}', parameters('profileName'), coalesce(parameters('customDomainNames'), createArray())[copyIndex()])]",
"dependsOn": [
"profile"
]
Expand Down Expand Up @@ -334,6 +340,13 @@
"name": "[format('{0}/{1}/{2}', parameters('profileName'), parameters('afdEndpointName'), parameters('name'))]",
"properties": {
"copy": [
{
"name": "customDomains",
"count": "[length(range(0, length(coalesce(parameters('customDomainNames'), createArray()))))]",
"input": {
"id": "[resourceId('Microsoft.Cdn/profiles/customDomains', parameters('profileName'), coalesce(parameters('customDomainNames'), createArray())[range(0, length(coalesce(parameters('customDomainNames'), createArray())))[copyIndex('customDomains')]])]"
}
},
{
"name": "ruleSets",
"count": "[length(parameters('ruleSets'))]",
Expand All @@ -343,7 +356,6 @@
}
],
"cacheConfiguration": "[parameters('cacheConfiguration')]",
"customDomains": "[if(not(empty(parameters('customDomainName'))), createArray(createObject('id', resourceId('Microsoft.Cdn/profiles/customDomains', parameters('profileName'), coalesce(parameters('customDomainName'), '')))), createArray())]",
"enabledState": "[parameters('enabledState')]",
"forwardingProtocol": "[parameters('forwardingProtocol')]",
"httpsRedirect": "[parameters('httpsRedirect')]",
Expand Down Expand Up @@ -421,4 +433,4 @@
"value": "[reference('afdEndpoint', '2023-05-01', 'full').location]"
}
}
}
}
8 changes: 4 additions & 4 deletions avm/res/cdn/profile/afdEndpoint/route/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This module deploys a CDN Profile AFD Endpoint route.
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`cacheConfiguration`](#parameter-cacheconfiguration) | object | The caching configuration for this route. To disable caching, do not provide a cacheConfiguration object. |
| [`customDomainName`](#parameter-customdomainname) | string | The name of the custom domain. The custom domain must be defined in the profile customDomains. |
| [`customDomainNames`](#parameter-customdomainnames) | array | The names of the custom domains. The custom domains must be defined in the profile customDomains array. |
| [`enabledState`](#parameter-enabledstate) | string | Whether this route is enabled. |
| [`forwardingProtocol`](#parameter-forwardingprotocol) | string | The protocol this rule will use when forwarding traffic to backends. |
| [`httpsRedirect`](#parameter-httpsredirect) | string | Whether to automatically redirect HTTP traffic to HTTPS traffic. |
Expand Down Expand Up @@ -77,12 +77,12 @@ The caching configuration for this route. To disable caching, do not provide a c
- Required: No
- Type: object

### Parameter: `customDomainName`
### Parameter: `customDomainNames`

The name of the custom domain. The custom domain must be defined in the profile customDomains.
The names of the custom domains. The custom domains must be defined in the profile customDomains array.

- Required: No
- Type: string
- Type: array

### Parameter: `enabledState`

Expand Down
23 changes: 11 additions & 12 deletions avm/res/cdn/profile/afdEndpoint/route/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ param afdEndpointName string
@description('Optional. The caching configuration for this route. To disable caching, do not provide a cacheConfiguration object.')
param cacheConfiguration object?

@description('Optional. The name of the custom domain. The custom domain must be defined in the profile customDomains.')
param customDomainName string?
@description('Optional. The names of the custom domains. The custom domains must be defined in the profile customDomains array.')
param customDomainNames string[]?

@allowed([
'HttpOnly'
Expand Down Expand Up @@ -69,10 +69,11 @@ resource profile 'Microsoft.Cdn/profiles@2023-05-01' existing = {
name: afdEndpointName
}

resource customDomain 'customDomains@2023-05-01' existing =
if (!empty(customDomainName)) {
name: customDomainName ?? ''
resource customDomains 'customDomains@2023-05-01' existing = [
for customDomainName in (customDomainNames ?? []): {
name: customDomainName
}
]

resource originGroup 'originGroups@2023-05-01' existing = {
name: originGroupName
Expand All @@ -90,13 +91,11 @@ resource route 'Microsoft.Cdn/profiles/afdEndpoints/routes@2023-05-01' = {
parent: profile::afdEndpoint
properties: {
cacheConfiguration: cacheConfiguration
customDomains: !empty(customDomainName)
? [
{
id: profile::customDomain.id
}
]
: []
customDomains: [
for index in range(0, length(customDomainNames ?? [])): {
id: profile::customDomains[index].id
}
]
enabledState: enabledState
forwardingProtocol: forwardingProtocol
httpsRedirect: httpsRedirect
Expand Down
32 changes: 22 additions & 10 deletions avm/res/cdn/profile/afdEndpoint/route/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "8525791914559803218"
"version": "0.26.170.59819",
"templateHash": "5770374289363120600"
},
"name": "CDN Profiles AFD Endpoint Route",
"description": "This module deploys a CDN Profile AFD Endpoint route.",
Expand Down Expand Up @@ -38,11 +38,14 @@
"description": "Optional. The caching configuration for this route. To disable caching, do not provide a cacheConfiguration object."
}
},
"customDomainName": {
"type": "string",
"customDomainNames": {
"type": "array",
"items": {
"type": "string"
},
"nullable": true,
"metadata": {
"description": "Optional. The name of the custom domain. The custom domain must be defined in the profile customDomains."
"description": "Optional. The names of the custom domains. The custom domains must be defined in the profile customDomains array."
}
},
"forwardingProtocol": {
Expand Down Expand Up @@ -139,12 +142,15 @@
"profile"
]
},
"profile::customDomain": {
"condition": "[not(empty(parameters('customDomainName')))]",
"profile::customDomains": {
"copy": {
"name": "customDomains",
"count": "[length(coalesce(parameters('customDomainNames'), createArray()))]"
},
"existing": true,
"type": "Microsoft.Cdn/profiles/customDomains",
"apiVersion": "2023-05-01",
"name": "[format('{0}/{1}', parameters('profileName'), coalesce(parameters('customDomainName'), ''))]",
"name": "[format('{0}/{1}', parameters('profileName'), coalesce(parameters('customDomainNames'), createArray())[copyIndex()])]",
"dependsOn": [
"profile"
]
Expand Down Expand Up @@ -183,6 +189,13 @@
"name": "[format('{0}/{1}/{2}', parameters('profileName'), parameters('afdEndpointName'), parameters('name'))]",
"properties": {
"copy": [
{
"name": "customDomains",
"count": "[length(range(0, length(coalesce(parameters('customDomainNames'), createArray()))))]",
"input": {
"id": "[resourceId('Microsoft.Cdn/profiles/customDomains', parameters('profileName'), coalesce(parameters('customDomainNames'), createArray())[range(0, length(coalesce(parameters('customDomainNames'), createArray())))[copyIndex('customDomains')]])]"
}
},
{
"name": "ruleSets",
"count": "[length(parameters('ruleSets'))]",
Expand All @@ -192,7 +205,6 @@
}
],
"cacheConfiguration": "[parameters('cacheConfiguration')]",
"customDomains": "[if(not(empty(parameters('customDomainName'))), createArray(createObject('id', resourceId('Microsoft.Cdn/profiles/customDomains', parameters('profileName'), coalesce(parameters('customDomainName'), '')))), createArray())]",
"enabledState": "[parameters('enabledState')]",
"forwardingProtocol": "[parameters('forwardingProtocol')]",
"httpsRedirect": "[parameters('httpsRedirect')]",
Expand Down Expand Up @@ -232,4 +244,4 @@
"value": "[resourceGroup().name]"
}
}
}
}
6 changes: 3 additions & 3 deletions avm/res/cdn/profile/customdomain/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "15657388199001378642"
"version": "0.26.170.59819",
"templateHash": "15721665305636481516"
},
"name": "CDN Profiles Custom Domains",
"description": "This module deploys a CDN Profile Custom Domains.",
Expand Down Expand Up @@ -121,4 +121,4 @@
"value": "[resourceGroup().name]"
}
}
}
}
10 changes: 5 additions & 5 deletions avm/res/cdn/profile/endpoint/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "5516612458443504281"
"version": "0.26.170.59819",
"templateHash": "2906172435071993445"
},
"name": "CDN Profiles Endpoints",
"description": "This module deploys a CDN Profile Endpoint.",
Expand Down Expand Up @@ -125,8 +125,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "11112660703037023992"
"version": "0.26.170.59819",
"templateHash": "3665403791951260301"
},
"name": "CDN Profiles Endpoints Origins",
"description": "This module deploys a CDN Profile Endpoint Origin.",
Expand Down Expand Up @@ -323,4 +323,4 @@
"value": "[reference('endpoint')]"
}
}
}
}
6 changes: 3 additions & 3 deletions avm/res/cdn/profile/endpoint/origin/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.54.24096",
"templateHash": "11112660703037023992"
"version": "0.26.170.59819",
"templateHash": "3665403791951260301"
},
"name": "CDN Profiles Endpoints Origins",
"description": "This module deploys a CDN Profile Endpoint Origin.",
Expand Down Expand Up @@ -158,4 +158,4 @@
"value": "[reference('endpoint', '2021-06-01', 'full').location]"
}
}
}
}
Loading

0 comments on commit 95f6aa9

Please sign in to comment.