Skip to content

Commit

Permalink
feat: Update avm/res/web/static-site - Add additional param for `pu…
Browse files Browse the repository at this point in the history
…blicNetworkAccess` (#4286)

## Description

<!--
>Thank you for your contribution !
> Please include a summary of the change and which issue is fixed.
> Please also include the context.
> List any dependencies that are required for this change.

Fixes #123
Fixes #456
Closes #123
Closes #456
-->


#Closes #4283

## Pipeline Reference

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

| Pipeline |
| -------- |
|
[![avm.res.web.static-site](https://github.com/ChrisSidebotham/bicep-registry-modules/actions/workflows/avm.res.web.static-site.yml/badge.svg?branch=swa-updates&event=workflow_dispatch)](https://github.com/ChrisSidebotham/bicep-registry-modules/actions/workflows/avm.res.web.static-site.yml)
|

## Type of Change

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

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [ ] Azure Verified Module updates:
- [x] 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.
- [ ] 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 date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Co-authored-by: Erika Gressi <[email protected]>
  • Loading branch information
ChrisSidebotham and eriqua authored Mar 1, 2025
1 parent cc0da74 commit ea9bcc9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
24 changes: 23 additions & 1 deletion avm/res/web/static-site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This module deploys a Static Web App.
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |
| `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` | [2021-03-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Web/2021-03-01/staticSites) |
| `Microsoft.Web/staticSites` | [2024-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Web/2024-04-01/staticSites) |
| `Microsoft.Web/staticSites/config` | [2022-03-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Web/2022-03-01/staticSites/config) |
| `Microsoft.Web/staticSites/customDomains` | [2022-03-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Web/2022-03-01/staticSites/customDomains) |
| `Microsoft.Web/staticSites/linkedBackends` | [2022-03-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Web/2022-03-01/staticSites/linkedBackends) |
Expand Down Expand Up @@ -156,6 +156,7 @@ module staticSite 'br/public:avm/res/web/static-site:<version>' = {
subnetResourceId: '<subnetResourceId>'
}
]
publicNetworkAccess: 'Enabled'
roleAssignments: [
{
name: 'ba1328f0-c7ab-47bf-afbf-0637b9c02bbe'
Expand Down Expand Up @@ -272,6 +273,9 @@ module staticSite 'br/public:avm/res/web/static-site:<version>' = {
}
]
},
"publicNetworkAccess": {
"value": "Enabled"
},
"roleAssignments": {
"value": [
{
Expand Down Expand Up @@ -374,6 +378,7 @@ param privateEndpoints = [
subnetResourceId: '<subnetResourceId>'
}
]
param publicNetworkAccess = 'Enabled'
param roleAssignments = [
{
name: 'ba1328f0-c7ab-47bf-afbf-0637b9c02bbe'
Expand Down Expand Up @@ -619,6 +624,7 @@ param tags = {
| [`managedIdentities`](#parameter-managedidentities) | object | The managed identity definition for this resource. |
| [`privateEndpoints`](#parameter-privateendpoints) | array | Configuration details for private endpoints. For security reasons, it is recommended to use private endpoints whenever possible. Note, requires the 'sku' to be 'Standard'. |
| [`provider`](#parameter-provider) | string | The provider that submitted the last deployment to the primary environment of the static site. |
| [`publicNetworkAccess`](#parameter-publicnetworkaccess) | string | Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set. |
| [`repositoryToken`](#parameter-repositorytoken) | securestring | The Personal Access Token for accessing the GitHub repository. |
| [`repositoryUrl`](#parameter-repositoryurl) | string | The name of the GitHub repository. |
| [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignments to create. |
Expand Down Expand Up @@ -1204,6 +1210,22 @@ The provider that submitted the last deployment to the primary environment of th
- Type: string
- Default: `'None'`

### Parameter: `publicNetworkAccess`

Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set.

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

### Parameter: `repositoryToken`

The Personal Access Token for accessing the GitHub repository.
Expand Down
13 changes: 12 additions & 1 deletion avm/res/web/static-site/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ param functionAppSettings object = {}
@description('Optional. The custom domains associated with this static site. The deployment will fail as long as the validation records are not present.')
param customDomains array = []

@description('Optional. Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set.')
@allowed([
''
'Enabled'
'Disabled'
])
param publicNetworkAccess string = ''

var enableReferencedModulesTelemetry = false

var formattedUserAssignedIdentities = reduce(
Expand Down Expand Up @@ -157,7 +165,7 @@ resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableT
}
}

resource staticSite 'Microsoft.Web/staticSites@2021-03-01' = {
resource staticSite 'Microsoft.Web/staticSites@2024-04-01' = {
name: name
location: location
tags: tags
Expand All @@ -176,6 +184,9 @@ resource staticSite 'Microsoft.Web/staticSites@2021-03-01' = {
repositoryToken: repositoryToken
repositoryUrl: repositoryUrl
templateProperties: templateProperties
publicNetworkAccess: !empty(publicNetworkAccess)
? any(publicNetworkAccess)
: (!empty(privateEndpoints) ? 'Disabled' : null)
}
}

Expand Down
23 changes: 18 additions & 5 deletions avm/res/web/static-site/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.33.93.31351",
"templateHash": "15301262394636824201"
"templateHash": "16463208866903865966"
},
"name": "Static Web Apps",
"description": "This module deploys a Static Web App."
Expand Down Expand Up @@ -635,6 +635,18 @@
"metadata": {
"description": "Optional. The custom domains associated with this static site. The deployment will fail as long as the validation records are not present."
}
},
"publicNetworkAccess": {
"type": "string",
"defaultValue": "",
"allowedValues": [
"",
"Enabled",
"Disabled"
],
"metadata": {
"description": "Optional. Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set."
}
}
},
"variables": {
Expand Down Expand Up @@ -681,7 +693,7 @@
},
"staticSite": {
"type": "Microsoft.Web/staticSites",
"apiVersion": "2021-03-01",
"apiVersion": "2024-04-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
Expand All @@ -699,7 +711,8 @@
"buildProperties": "[parameters('buildProperties')]",
"repositoryToken": "[parameters('repositoryToken')]",
"repositoryUrl": "[parameters('repositoryUrl')]",
"templateProperties": "[parameters('templateProperties')]"
"templateProperties": "[parameters('templateProperties')]",
"publicNetworkAccess": "[if(not(empty(parameters('publicNetworkAccess'))), parameters('publicNetworkAccess'), if(not(empty(parameters('privateEndpoints'))), 'Disabled', null()))]"
}
},
"staticSite_lock": {
Expand Down Expand Up @@ -1907,14 +1920,14 @@
"metadata": {
"description": "The principal ID of the system assigned identity."
},
"value": "[tryGet(tryGet(reference('staticSite', '2021-03-01', 'full'), 'identity'), 'principalId')]"
"value": "[tryGet(tryGet(reference('staticSite', '2024-04-01', 'full'), 'identity'), 'principalId')]"
},
"location": {
"type": "string",
"metadata": {
"description": "The location the resource was deployed into."
},
"value": "[reference('staticSite', '2021-03-01', 'full').location]"
"value": "[reference('staticSite', '2024-04-01', 'full').location]"
},
"defaultHostname": {
"type": "string",
Expand Down
1 change: 1 addition & 0 deletions avm/res/web/static-site/tests/e2e/max/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ module testDeployment '../../../main.bicep' = [
kind: 'CanNotDelete'
name: 'myCustomLockName'
}
publicNetworkAccess: 'Enabled'
privateEndpoints: [
{
subnetResourceId: nestedDependencies.outputs.subnetResourceId
Expand Down

0 comments on commit ea9bcc9

Please sign in to comment.