Skip to content

Commit

Permalink
fix: test updates for az defaults (#3344)
Browse files Browse the repository at this point in the history
## Description

Addressing the AZ defaults now that the PSRule test bug has been
addressed
[here](microsoft/PSRule#1900 (comment)).


## Pipeline Reference

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

| Pipeline |
| -------- |

|[![avm.res.web.serverfarm](https://github.com/tsc-buddy/bicep-registry-modules/actions/workflows/avm.res.web.serverfarm.yml/badge.svg?branch=fix%2Fasp-zr-default)](https://github.com/tsc-buddy/bicep-registry-modules/actions/workflows/avm.res.web.serverfarm.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:
- [ ] 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.
- [x] 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
tsc-buddy and eriqua authored Sep 26, 2024
1 parent 57769c2 commit 717e7fd
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 75 deletions.
96 changes: 45 additions & 51 deletions avm/res/web/serverfarm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
params: {
// Required parameters
name: 'wsfmin001'
skuCapacity: 2
skuName: 'S1'
// Non-required parameters
location: '<location>'
}
Expand All @@ -70,12 +68,6 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
"name": {
"value": "wsfmin001"
},
"skuCapacity": {
"value": 2
},
"skuName": {
"value": "S1"
},
// Non-required parameters
"location": {
"value": "<location>"
Expand All @@ -102,8 +94,6 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
params: {
// Required parameters
name: 'wsfmax001'
skuCapacity: 1
skuName: 'S1'
// Non-required parameters
diagnosticSettings: [
{
Expand Down Expand Up @@ -143,12 +133,14 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
roleDefinitionIdOrName: '<roleDefinitionIdOrName>'
}
]
skuCapacity: 3
skuName: 'P1v3'
tags: {
Environment: 'Non-Prod'
'hidden-title': 'This is visible in the resource name'
Role: 'DeploymentValidation'
}
zoneRedundant: false
zoneRedundant: true
}
}
```
Expand All @@ -169,12 +161,6 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
"name": {
"value": "wsfmax001"
},
"skuCapacity": {
"value": 1
},
"skuName": {
"value": "S1"
},
// Non-required parameters
"diagnosticSettings": {
"value": [
Expand Down Expand Up @@ -226,6 +212,12 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
}
]
},
"skuCapacity": {
"value": 3
},
"skuName": {
"value": "P1v3"
},
"tags": {
"value": {
"Environment": "Non-Prod",
Expand All @@ -234,7 +226,7 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
}
},
"zoneRedundant": {
"value": false
"value": true
}
}
}
Expand All @@ -258,8 +250,6 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
params: {
// Required parameters
name: 'wsfwaf001'
skuCapacity: 2
skuName: 'P1v3'
// Non-required parameters
diagnosticSettings: [
{
Expand All @@ -281,12 +271,14 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
kind: 'CanNotDelete'
name: 'lock'
}
skuCapacity: 3
skuName: 'P1v3'
tags: {
Environment: 'Non-Prod'
'hidden-title': 'This is visible in the resource name'
Role: 'DeploymentValidation'
}
zoneRedundant: false
zoneRedundant: true
}
}
```
Expand All @@ -307,12 +299,6 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
"name": {
"value": "wsfwaf001"
},
"skuCapacity": {
"value": 2
},
"skuName": {
"value": "P1v3"
},
// Non-required parameters
"diagnosticSettings": {
"value": [
Expand Down Expand Up @@ -342,6 +328,12 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
"name": "lock"
}
},
"skuCapacity": {
"value": 3
},
"skuName": {
"value": "P1v3"
},
"tags": {
"value": {
"Environment": "Non-Prod",
Expand All @@ -350,7 +342,7 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
}
},
"zoneRedundant": {
"value": false
"value": true
}
}
}
Expand All @@ -366,8 +358,6 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`name`](#parameter-name) | string | Name of the app service plan. |
| [`skuCapacity`](#parameter-skucapacity) | int | Number of workers associated with the App Service Plan. |
| [`skuName`](#parameter-skuname) | string | The name of the SKU will Determine the tier, size, family of the App Service Plan. |

**Conditional parameters**

Expand All @@ -389,6 +379,8 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
| [`maximumElasticWorkerCount`](#parameter-maximumelasticworkercount) | int | Maximum number of total workers allowed for this ElasticScaleEnabled App Service Plan. |
| [`perSiteScaling`](#parameter-persitescaling) | bool | If true, apps assigned to this App Service plan can be scaled independently. If false, apps assigned to this App Service plan will scale to all instances of the plan. |
| [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignments to create. |
| [`skuCapacity`](#parameter-skucapacity) | int | Number of workers associated with the App Service Plan. This defaults to 3, to leverage availability zones. |
| [`skuName`](#parameter-skuname) | string | The name of the SKU will Determine the tier, size, family of the App Service Plan. This defaults to P1v3 to leverage availability zones. |
| [`tags`](#parameter-tags) | object | Tags of the resource. |
| [`targetWorkerCount`](#parameter-targetworkercount) | int | Scaling worker count. |
| [`targetWorkerSize`](#parameter-targetworkersize) | int | The instance size of the hosting plan (small, medium, or large). |
Expand All @@ -402,27 +394,6 @@ Name of the app service plan.
- Required: Yes
- Type: string

### Parameter: `skuCapacity`

Number of workers associated with the App Service Plan.

- Required: Yes
- Type: int

### Parameter: `skuName`

The name of the SKU will Determine the tier, size, family of the App Service Plan.

- Required: Yes
- Type: string
- Example:
```Bicep
'F1'
'B1'
'P1v3'
'I1v2'
```

### Parameter: `reserved`

Defaults to false when creating Windows/app App Service Plan. Required if creating a Linux App Service Plan and must be set to true.
Expand Down Expand Up @@ -739,6 +710,29 @@ The principal type of the assigned principal ID.
]
```

### Parameter: `skuCapacity`

Number of workers associated with the App Service Plan. This defaults to 3, to leverage availability zones.

- Required: No
- Type: int
- Default: `3`

### Parameter: `skuName`

The name of the SKU will Determine the tier, size, family of the App Service Plan. This defaults to P1v3 to leverage availability zones.

- Required: No
- Type: string
- Default: `'P1v3'`
- Example:
```Bicep
'F1'
'B1'
'P1v3'
'I1v2'
```

### Parameter: `tags`

Tags of the resource.
Expand Down
19 changes: 10 additions & 9 deletions avm/res/web/serverfarm/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata owner = 'Azure/module-maintainers'
@maxLength(60)
param name string

@description('Required. The name of the SKU will Determine the tier, size, family of the App Service Plan.')
@description('Optional. The name of the SKU will Determine the tier, size, family of the App Service Plan. This defaults to P1v3 to leverage availability zones.')
@metadata({
example: '''
'F1'
Expand All @@ -16,10 +16,10 @@ param name string
'I1v2'
'''
})
param skuName string
param skuName string = 'P1v3'

@description('Required. Number of workers associated with the App Service Plan.')
param skuCapacity int
@description('Optional. Number of workers associated with the App Service Plan. This defaults to 3, to leverage availability zones.')
param skuCapacity int = 3

@description('Optional. Location for all resources.')
param location string = resourceGroup().location
Expand Down Expand Up @@ -185,11 +185,12 @@ resource appServicePlan_roleAssignments 'Microsoft.Authorization/roleAssignments
for (roleAssignment, index) in (roleAssignments ?? []): {
name: guid(appServicePlan.id, roleAssignment.principalId, roleAssignment.roleDefinitionIdOrName)
properties: {
roleDefinitionId: contains(builtInRoleNames, roleAssignment.roleDefinitionIdOrName)
? builtInRoleNames[roleAssignment.roleDefinitionIdOrName]
: contains(roleAssignment.roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/')
? roleAssignment.roleDefinitionIdOrName
: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleAssignment.roleDefinitionIdOrName)
roleDefinitionId: builtInRoleNames[?roleAssignment.roleDefinitionIdOrName] ?? (contains(
roleAssignment.roleDefinitionIdOrName,
'/providers/Microsoft.Authorization/roleDefinitions/'
)
? roleAssignment.roleDefinitionIdOrName
: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleAssignment.roleDefinitionIdOrName))
principalId: roleAssignment.principalId
description: roleAssignment.?description
principalType: roleAssignment.?principalType
Expand Down
12 changes: 7 additions & 5 deletions avm/res/web/serverfarm/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "16609348340052214807"
"version": "0.30.3.12046",
"templateHash": "12599229174633311842"
},
"name": "App Service Plan",
"description": "This module deploys an App Service Plan.",
Expand Down Expand Up @@ -203,15 +203,17 @@
},
"skuName": {
"type": "string",
"defaultValue": "P1v3",
"metadata": {
"example": " 'F1'\n 'B1'\n 'P1v3'\n 'I1v2'\n ",
"description": "Required. The name of the SKU will Determine the tier, size, family of the App Service Plan."
"description": "Optional. The name of the SKU will Determine the tier, size, family of the App Service Plan. This defaults to P1v3 to leverage availability zones."
}
},
"skuCapacity": {
"type": "int",
"defaultValue": 3,
"metadata": {
"description": "Required. Number of workers associated with the App Service Plan."
"description": "Optional. Number of workers associated with the App Service Plan. This defaults to 3, to leverage availability zones."
}
},
"location": {
Expand Down Expand Up @@ -447,7 +449,7 @@
"scope": "[format('Microsoft.Web/serverfarms/{0}', parameters('name'))]",
"name": "[guid(resourceId('Microsoft.Web/serverfarms', parameters('name')), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId, coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)]",
"properties": {
"roleDefinitionId": "[if(contains(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName), variables('builtInRoleNames')[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName], if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)))]",
"roleDefinitionId": "[coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)))]",
"principalId": "[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId]",
"description": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'description')]",
"principalType": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'principalType')]",
Expand Down
4 changes: 1 addition & 3 deletions avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ param serviceShort string = 'wsfmin'
param namePrefix string = '#_namePrefix_#'

#disable-next-line no-hardcoded-location // Just a value to avoid ongoing capacity challenges
var enforcedLocation = 'eastus'
var enforcedLocation = 'australiaeast'

// ============ //
// Dependencies //
Expand All @@ -43,8 +43,6 @@ module testDeployment '../../../main.bicep' = [
params: {
name: '${namePrefix}${serviceShort}001'
location: enforcedLocation
skuName: 'S1'
skuCapacity: 2
}
}
]
8 changes: 4 additions & 4 deletions avm/res/web/serverfarm/tests/e2e/max/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ param serviceShort string = 'wsfmax'
param namePrefix string = '#_namePrefix_#'

#disable-next-line no-hardcoded-location // Just a value to avoid ongoing capacity challenges
var enforcedLocation = 'eastus'
var enforcedLocation = 'australiaeast'

// ============ //
// Dependencies //
Expand Down Expand Up @@ -64,10 +64,10 @@ module testDeployment '../../../main.bicep' = [
params: {
name: '${namePrefix}${serviceShort}001'
location: enforcedLocation
skuName: 'S1'
skuCapacity: 1
skuName: 'P1v3'
skuCapacity: 3
perSiteScaling: true
zoneRedundant: false
zoneRedundant: true
kind: 'App'
lock: {
name: 'lock'
Expand Down
6 changes: 3 additions & 3 deletions avm/res/web/serverfarm/tests/e2e/waf-aligned/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ param serviceShort string = 'wsfwaf'
param namePrefix string = '#_namePrefix_#'

#disable-next-line no-hardcoded-location // Just a value to avoid ongoing capacity challenges
var enforcedLocation = 'eastus'
var enforcedLocation = 'australiaeast'

// ============ //
// Dependencies //
Expand Down Expand Up @@ -56,8 +56,8 @@ module testDeployment '../../../main.bicep' = [
name: '${namePrefix}${serviceShort}001'
location: enforcedLocation
skuName: 'P1v3'
skuCapacity: 2
zoneRedundant: false
skuCapacity: 3
zoneRedundant: true
kind: 'App'
lock: {
name: 'lock'
Expand Down

0 comments on commit 717e7fd

Please sign in to comment.