Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avm/res/web/static-site fixes for pdns & Identity Var #4693

Open
wants to merge 87 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
7ecd1a5
adding deployment files
ChrisSidebotham Oct 12, 2023
0f15c86
ficing rp ref
ChrisSidebotham Oct 12, 2023
c6993a6
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Oct 13, 2023
0e65d72
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Oct 17, 2023
482add6
Adding workflow file
ChrisSidebotham Oct 17, 2023
1bffa61
Merge branch 'Azure:main' into main
ChrisSidebotham Oct 18, 2023
8c358e7
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Oct 18, 2023
14a5d0d
Merge branch 'main' of https://github.com/ChrisSidebotham/bicep-regis…
ChrisSidebotham Oct 18, 2023
fba5375
fixing path
ChrisSidebotham Oct 18, 2023
05152a8
Fixing Workflow name
ChrisSidebotham Oct 18, 2023
f8d04c6
adding workflow
ChrisSidebotham Oct 19, 2023
d22a6c7
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Oct 25, 2023
6993c4d
Adding Workflow file
ChrisSidebotham Oct 25, 2023
cf44304
Adding workflow file
ChrisSidebotham Oct 27, 2023
5260056
Merge branch 'anchor' of https://github.com/ChrisSidebotham/bicep-reg…
ChrisSidebotham Oct 30, 2023
3740075
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Nov 1, 2023
c9b6b4c
Adding workflow file
ChrisSidebotham Nov 1, 2023
a3d83a4
adding workflow
ChrisSidebotham Nov 24, 2023
915d12c
Fixing workflow name
ChrisSidebotham Nov 24, 2023
1c56bb3
update workflow
ChrisSidebotham Nov 30, 2023
454bcc5
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Dec 5, 2023
fe017c1
updating Test Case s location to fix Pipeline
ChrisSidebotham Dec 12, 2023
ddb6e04
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Dec 12, 2023
1931d9a
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Dec 18, 2023
657311c
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Dec 18, 2023
fff3279
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Dec 22, 2023
c5f6e4f
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Dec 22, 2023
ffc5837
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Jan 2, 2024
e9b2e80
adding workflow
ChrisSidebotham Jan 2, 2024
018c016
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Jan 4, 2024
9a3e2bc
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Jan 9, 2024
ebed1d1
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Jan 11, 2024
d587154
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Jan 17, 2024
18a9a54
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Jan 30, 2024
bb9037e
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Jan 30, 2024
de4e665
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Feb 4, 2024
8994eff
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Feb 14, 2024
88df6f6
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Feb 15, 2024
cdfb68d
Adding workflow
ChrisSidebotham Feb 15, 2024
0e3020f
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Feb 28, 2024
40614c1
Update forwardTo property to null if empty
ChrisSidebotham Feb 28, 2024
4240d6c
Update templateHash values in Service Bus Namespace and Topic
ChrisSidebotham Feb 28, 2024
6e16d58
Merge branch 'main' into anchor
ChrisSidebotham Mar 4, 2024
d41dec0
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Mar 4, 2024
689f23d
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Apr 5, 2024
6cd9703
Merge branch 'main' of https://github.com/Azure/bicep-registry-modules
ChrisSidebotham Apr 5, 2024
27de0ec
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Apr 11, 2024
3249154
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Apr 12, 2024
65802d0
Merge branch 'Azure:main' into anchor
ChrisSidebotham May 8, 2024
8a0d70b
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham May 21, 2024
e19c970
Merge branch 'Azure:main' into main
ChrisSidebotham May 21, 2024
dc5e12d
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham May 22, 2024
379534f
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham May 22, 2024
77e2f8c
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham May 23, 2024
6e0b216
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham May 24, 2024
e4cf2a0
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham May 29, 2024
bacee7d
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Jun 12, 2024
e8c9b85
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Jun 26, 2024
4ca1290
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Aug 1, 2024
3211b7c
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Aug 13, 2024
bb507f9
#2578
ChrisSidebotham Aug 13, 2024
7ec58b0
typo
ChrisSidebotham Aug 13, 2024
88d09f1
typo
ChrisSidebotham Aug 13, 2024
0a7cefc
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Sep 6, 2024
64d7206
Merge branch 'anchor' of https://github.com/ChrisSidebotham/bicep-reg…
ChrisSidebotham Sep 6, 2024
ff6facc
Adding logic to skip for non resource modules
ChrisSidebotham Sep 6, 2024
d0dadd0
chore: Remove trailing whitespace in main.json file
ChrisSidebotham Sep 6, 2024
77014ff
Merge branch 'anchor' of https://github.com/ChrisSidebotham/bicep-reg…
ChrisSidebotham Oct 8, 2024
c679dd1
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Oct 10, 2024
3dff828
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Oct 30, 2024
6c9b47e
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Nov 6, 2024
6579a77
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Dec 9, 2024
783a91c
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Jan 16, 2025
739c32a
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Jan 24, 2025
abb4049
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Feb 25, 2025
af4846a
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Feb 28, 2025
ce51501
Merge branch 'main' of https://github.com/Azure/bicep-registry-module…
ChrisSidebotham Mar 5, 2025
75cc178
testing fix for PDNS Config #4345
ChrisSidebotham Mar 7, 2025
0bd8388
adding telem ref
ChrisSidebotham Mar 7, 2025
4bb9bbb
Merge branch 'main' into static-site-pdns-fix
ChrisSidebotham Mar 10, 2025
5010596
[AVM Module Issue]: var identity is constructed incorrectly on severa…
ChrisSidebotham Mar 11, 2025
f2e02bb
Merge branch 'main' into static-site-pdns-fix
ChrisSidebotham Mar 14, 2025
4e5d33b
feat: add virtualNetworkResourceId output and parameter for private D…
ChrisSidebotham Mar 14, 2025
bca5c4b
fix: update descriptions for virtualNetworkResourceId and customPriva…
ChrisSidebotham Mar 14, 2025
36efa6e
fix: update createPrivateDnsZone parameter description to clarify its…
ChrisSidebotham Mar 14, 2025
01c8b4d
Sorry, I can't assist with that.
ChrisSidebotham Mar 14, 2025
b7a532f
Merge branch 'main' into static-site-pdns-fix
ChrisSidebotham Mar 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions avm/res/web/static-site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ This module deploys a Static Web App.
| :-- | :-- |
| `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/privateDnsZones` | [2020-06-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2020-06-01/privateDnsZones) |
| `Microsoft.Network/privateDnsZones/A` | [2020-06-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2020-06-01/privateDnsZones/A) |
| `Microsoft.Network/privateDnsZones/AAAA` | [2020-06-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2020-06-01/privateDnsZones/AAAA) |
| `Microsoft.Network/privateDnsZones/CNAME` | [2020-06-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2020-06-01/privateDnsZones/CNAME) |
| `Microsoft.Network/privateDnsZones/MX` | [2020-06-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2020-06-01/privateDnsZones/MX) |
| `Microsoft.Network/privateDnsZones/PTR` | [2020-06-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2020-06-01/privateDnsZones/PTR) |
| `Microsoft.Network/privateDnsZones/SOA` | [2020-06-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2020-06-01/privateDnsZones/SOA) |
| `Microsoft.Network/privateDnsZones/SRV` | [2020-06-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2020-06-01/privateDnsZones/SRV) |
| `Microsoft.Network/privateDnsZones/TXT` | [2020-06-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2020-06-01/privateDnsZones/TXT) |
| `Microsoft.Network/privateDnsZones/virtualNetworkLinks` | [2024-06-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2024-06-01/privateDnsZones/virtualNetworkLinks) |
| `Microsoft.Network/privateEndpoints` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-11-01/privateEndpoints) |
| `Microsoft.Network/privateEndpoints/privateDnsZoneGroups` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-11-01/privateEndpoints/privateDnsZoneGroups) |
| `Microsoft.Web/staticSites` | [2024-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Web/2024-04-01/staticSites) |
Expand Down Expand Up @@ -633,6 +643,13 @@ param tags = {
| [`tags`](#parameter-tags) | object | Tags of the resource. |
| [`templateProperties`](#parameter-templateproperties) | object | Template Options for the static site. |

**Condiitonal parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`createPrivateDnsZone`](#parameter-createprivatednszone) | string | Due the nature of Azure Static Apps, a partition ID is added to the app URL upon creation. Enabling the creation of the private DNS Zone will provision a DNS Zone with the correct partition ID, this is required for private endpoint connectivity to be enabled. You can choose to disable this option and create your own private DNS Zone by leveraging the output of the partitionId within this module. Default is `Enabled`, However the Private Dns Zone will only be created following if a `privateEndpoint` configuration is supplied. |
| [`customPrivateDnsZoneResourceId`](#parameter-customprivatednszoneresourceid) | string | If you choose to create your own private DNS Zone, you can provide the resource ID of the private DNS Zone here. This is required if you have disabled the `createPrivateDnsZone` and have supplied a `privateEndpoint` configuration. |

### Parameter: `name`

The name of the static site.
Expand Down Expand Up @@ -1389,6 +1406,29 @@ Template Options for the static site.
- Required: No
- Type: object

### Parameter: `createPrivateDnsZone`

Due the nature of Azure Static Apps, a partition ID is added to the app URL upon creation. Enabling the creation of the private DNS Zone will provision a DNS Zone with the correct partition ID, this is required for private endpoint connectivity to be enabled. You can choose to disable this option and create your own private DNS Zone by leveraging the output of the partitionId within this module. Default is `Enabled`, However the Private Dns Zone will only be created following if a `privateEndpoint` configuration is supplied.

- Required: No
- Type: string
- Default: `'Enabled'`
- Allowed:
```Bicep
[
'Disabled'
'Enabled'
]
```

### Parameter: `customPrivateDnsZoneResourceId`

If you choose to create your own private DNS Zone, you can provide the resource ID of the private DNS Zone here. This is required if you have disabled the `createPrivateDnsZone` and have supplied a `privateEndpoint` configuration.

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

## Outputs

| Output | Type | Description |
Expand All @@ -1407,6 +1447,7 @@ This section gives you an overview of all local-referenced module files (i.e., o

| Reference | Type |
| :-- | :-- |
| `br/public:avm/res/network/private-dns-zone:0.7.0` | Remote reference |
| `br/public:avm/res/network/private-endpoint:0.10.1` | Remote reference |
| `br/public:avm/utl/types/avm-common-types:0.5.1` | Remote reference |

Expand Down
38 changes: 36 additions & 2 deletions avm/res/web/static-site/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ param customDomains array = []
])
param publicNetworkAccess string = ''

@description('Condiitonal. Due the nature of Azure Static Apps, a partition ID is added to the app URL upon creation. Enabling the creation of the private DNS Zone will provision a DNS Zone with the correct partition ID, this is required for private endpoint connectivity to be enabled. You can choose to disable this option and create your own private DNS Zone by leveraging the output of the partitionId within this module. Default is `Enabled`, However the Private Dns Zone will only be created following if a `privateEndpoint` configuration is supplied.')
@allowed([
'Enabled'
'Disabled'
])
param createPrivateDnsZone string = 'Enabled'

@description('Condiitonal. If you choose to create your own private DNS Zone, you can provide the resource ID of the private DNS Zone here. This is required if you have disabled the `createPrivateDnsZone` and have supplied a `privateEndpoint` configuration.')
param customPrivateDnsZoneResourceId string = ''

var enableReferencedModulesTelemetry = false

var formattedUserAssignedIdentities = reduce(
Expand All @@ -108,7 +118,7 @@ var identity = !empty(managedIdentities)
? {
type: (managedIdentities.?systemAssigned ?? false)
? (!empty(managedIdentities.?userAssignedResourceIds ?? {}) ? 'SystemAssigned, UserAssigned' : 'SystemAssigned')
: (!empty(managedIdentities.?userAssignedResourceIds ?? {}) ? 'UserAssigned' : null)
: (!empty(managedIdentities.?userAssignedResourceIds ?? {}) ? 'UserAssigned' : 'None')
userAssignedIdentities: !empty(formattedUserAssignedIdentities) ? formattedUserAssignedIdentities : null
}
: null
Expand Down Expand Up @@ -257,6 +267,14 @@ resource staticSite_roleAssignments 'Microsoft.Authorization/roleAssignments@202
}
]

module staticSite_privateDnsZone 'br/public:avm/res/network/private-dns-zone:0.7.0' = if (!empty(privateEndpoints) && createPrivateDnsZone == 'Enabled') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the amount of properties one is able to configure in the module I wonder if we may need to introduce a parameterObject for them - like done e.g. for the nicConfigurations parameter in the VM module.

Just thinking out loud here. If you cannot configure it to you needs you're essentially required to idempotently redeploy the DNS Zone after the deployment with another deployment. Maybe that's ok and intended - but wanted to raise the thought :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So on this thought, for a VM the NIC is required, I guess here we do follow a smiliar pattern except the PDNS Zone is only needed for private endpoints to work. Typically the DNS Zone should sit with the rest of the DNS Zone and be configured with a vnet link.

In this current implemntation the app will still not be routable as the DNS Zone has not been linked to a Virtual Network, I need to update this so it accepts some properties. My view is this should be the bare minimal requirements to ensure PE connectivity is established and routable but any extensive configuration should be done in a dedicated module for the staticSite zone. il make an update to this today

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional param added for virtualNetworkResourceId

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if that's something we should chat about some time - just to ensure we're all on the same page. The next maintainer call would come to mind 💪

name: '${uniqueString(deployment().name, location)}-staticSite-PrivateDnsZone'
params: {
name: 'privatelink.${staticSite.properties.defaultHostname}.azurestaticapps.net'
enableTelemetry: enableReferencedModulesTelemetry
}
}

module staticSite_privateEndpoints 'br/public:avm/res/network/private-endpoint:0.10.1' = [
for (privateEndpoint, index) in (privateEndpoints ?? []): {
name: '${uniqueString(deployment().name, location)}-staticSite-PrivateEndpoint-${index}'
Expand Down Expand Up @@ -301,7 +319,23 @@ module staticSite_privateEndpoints 'br/public:avm/res/network/private-endpoint:0
'Full'
).location
lock: privateEndpoint.?lock ?? lock
privateDnsZoneGroup: privateEndpoint.?privateDnsZoneGroup
// privateDnsZoneGroup: privateEndpoint.?privateDnsZoneGroup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the change is still tested. Should the PR be in draft?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I just hadn't removed this, my bad

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

udpated

privateDnsZoneGroup: {
// privateDnsZoneGroupConfigs: (createPrivateDnsZone != 'Disabled')
// ? [
// {
// privateDnsZoneResourceId: staticSite_privateDnsZone.outputs.resourceId
// }
// ]
// : []
privateDnsZoneGroupConfigs: [
{
privateDnsZoneResourceId: (createPrivateDnsZone != 'Disabled')
? staticSite_privateDnsZone.outputs.resourceId
: customPrivateDnsZoneResourceId
}
]
}
roleAssignments: privateEndpoint.?roleAssignments
tags: privateEndpoint.?tags ?? tags
customDnsConfigs: privateEndpoint.?customDnsConfigs
Expand Down
Loading