From 4ba4576f613dd7de38ab9d9e7b3d26b0c9d395fe Mon Sep 17 00:00:00 2001 From: MrMCake Date: Sun, 4 Sep 2022 18:01:19 +0200 Subject: [PATCH 1/6] Updated ApplicationSecurityGroups to new dependency approach --- .../ms.network.applicationsecuritygroups.yml | 3 +- .../.test/default/dependencies.bicep | 14 +++++ .../.test/default/deploy.test.bicep | 54 +++++++++++++++++++ .../.test/parameters.json | 22 -------- .../applicationSecurityGroups/readme.md | 12 ++--- 5 files changed, 75 insertions(+), 30 deletions(-) create mode 100644 modules/Microsoft.Network/applicationSecurityGroups/.test/default/dependencies.bicep create mode 100644 modules/Microsoft.Network/applicationSecurityGroups/.test/default/deploy.test.bicep delete mode 100644 modules/Microsoft.Network/applicationSecurityGroups/.test/parameters.json diff --git a/.github/workflows/ms.network.applicationsecuritygroups.yml b/.github/workflows/ms.network.applicationsecuritygroups.yml index f91fd36990..e6080afa62 100644 --- a/.github/workflows/ms.network.applicationsecuritygroups.yml +++ b/.github/workflows/ms.network.applicationsecuritygroups.yml @@ -106,8 +106,7 @@ jobs: - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' uses: ./.github/actions/templates/validateModuleDeployment with: - templateFilePath: '${{ env.modulePath }}/deploy.bicep' - parameterFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' + templateFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' location: '${{ env.location }}' resourceGroupName: '${{ env.resourceGroupName }}' subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' diff --git a/modules/Microsoft.Network/applicationSecurityGroups/.test/default/dependencies.bicep b/modules/Microsoft.Network/applicationSecurityGroups/.test/default/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.Network/applicationSecurityGroups/.test/default/dependencies.bicep @@ -0,0 +1,14 @@ +@description('Optional. The location to deploy to.') +param location string = resourceGroup().location + +@description('Required. The name of the Managed Identity to create.') +param managedIdentityName string + +resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { + name: managedIdentityName + location: location +} + +@description('The principal ID of the created Managed Identity.') +output managedIdentityPrincipalId string = managedIdentity.properties.principalId + diff --git a/modules/Microsoft.Network/applicationSecurityGroups/.test/default/deploy.test.bicep b/modules/Microsoft.Network/applicationSecurityGroups/.test/default/deploy.test.bicep new file mode 100644 index 0000000000..aa48873379 --- /dev/null +++ b/modules/Microsoft.Network/applicationSecurityGroups/.test/default/deploy.test.bicep @@ -0,0 +1,54 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.network.applicationsecuritygroups-${serviceShort}-rg' + +@description('Optional. The location to deploy resources to') +param location string = deployment().location + +@description('Optional. A short identifier for the kind of deployment .Should be kept short to not run into resource-name length-constraints') +param serviceShort string = 'nasgdef' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +module resourceGroupResources 'dependencies.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-paramNested' + params: { + managedIdentityName: 'dep-<>-msi-${serviceShort}' + } +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: '<>${serviceShort}001' + lock: 'CanNotDelete' + roleAssignments: [ + { + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + roleDefinitionIdOrName: 'Reader' + } + ] + } +} diff --git a/modules/Microsoft.Network/applicationSecurityGroups/.test/parameters.json b/modules/Microsoft.Network/applicationSecurityGroups/.test/parameters.json deleted file mode 100644 index 8bfef178fc..0000000000 --- a/modules/Microsoft.Network/applicationSecurityGroups/.test/parameters.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-asg-x-001" - }, - "lock": { - "value": "CanNotDelete" - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - } - } -} diff --git a/modules/Microsoft.Network/applicationSecurityGroups/readme.md b/modules/Microsoft.Network/applicationSecurityGroups/readme.md index 4ed29d22e6..4468b38709 100644 --- a/modules/Microsoft.Network/applicationSecurityGroups/readme.md +++ b/modules/Microsoft.Network/applicationSecurityGroups/readme.md @@ -154,7 +154,7 @@ The following module usage examples are retrieved from the content of the files >**Note**: The name of each example is based on the name of the file from which it is taken. >**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order. -

Example 1: Parameters

+

Example 1: Default

@@ -162,16 +162,16 @@ The following module usage examples are retrieved from the content of the files ```bicep module applicationSecurityGroups './Microsoft.Network/applicationSecurityGroups/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-ApplicationSecurityGroups' + name: '${uniqueString(deployment().name)}-test-nasgdef' params: { // Required parameters - name: '<>-az-asg-x-001' + name: '<>nasgdef001' // Non-required parameters lock: 'CanNotDelete' roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } @@ -194,7 +194,7 @@ module applicationSecurityGroups './Microsoft.Network/applicationSecurityGroups/ "parameters": { // Required parameters "name": { - "value": "<>-az-asg-x-001" + "value": "<>nasgdef001" }, // Non-required parameters "lock": { @@ -204,7 +204,7 @@ module applicationSecurityGroups './Microsoft.Network/applicationSecurityGroups/ "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } From 975437b8e595800b25cb61dffb44fcc3a3ddaa9b Mon Sep 17 00:00:00 2001 From: MrMCake Date: Thu, 8 Sep 2022 19:14:05 +0200 Subject: [PATCH 2/6] Updated folder default to common. --- .../.test/{default => common}/dependencies.bicep | 0 .../.test/{default => common}/deploy.test.bicep | 0 modules/Microsoft.Network/applicationSecurityGroups/readme.md | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename modules/Microsoft.Network/applicationSecurityGroups/.test/{default => common}/dependencies.bicep (100%) rename modules/Microsoft.Network/applicationSecurityGroups/.test/{default => common}/deploy.test.bicep (100%) diff --git a/modules/Microsoft.Network/applicationSecurityGroups/.test/default/dependencies.bicep b/modules/Microsoft.Network/applicationSecurityGroups/.test/common/dependencies.bicep similarity index 100% rename from modules/Microsoft.Network/applicationSecurityGroups/.test/default/dependencies.bicep rename to modules/Microsoft.Network/applicationSecurityGroups/.test/common/dependencies.bicep diff --git a/modules/Microsoft.Network/applicationSecurityGroups/.test/default/deploy.test.bicep b/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep similarity index 100% rename from modules/Microsoft.Network/applicationSecurityGroups/.test/default/deploy.test.bicep rename to modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep diff --git a/modules/Microsoft.Network/applicationSecurityGroups/readme.md b/modules/Microsoft.Network/applicationSecurityGroups/readme.md index 4468b38709..b4fe0c11c3 100644 --- a/modules/Microsoft.Network/applicationSecurityGroups/readme.md +++ b/modules/Microsoft.Network/applicationSecurityGroups/readme.md @@ -154,7 +154,7 @@ The following module usage examples are retrieved from the content of the files >**Note**: The name of each example is based on the name of the file from which it is taken. >**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order. -

Example 1: Default

+

Example 1: Common

From a3b041285dadd0984b2d42bf6d05fb7cd6911e28 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 12:51:55 +0200 Subject: [PATCH 3/6] Update to latest --- .../applicationSecurityGroups/.test/common/deploy.test.bicep | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep b/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep index aa48873379..ad35b83ebf 100644 --- a/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep @@ -10,8 +10,8 @@ param resourceGroupName string = 'ms.network.applicationsecuritygroups-${service @description('Optional. The location to deploy resources to') param location string = deployment().location -@description('Optional. A short identifier for the kind of deployment .Should be kept short to not run into resource-name length-constraints') -param serviceShort string = 'nasgdef' +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints') +param serviceShort string = 'nasgcom' // =========== // // Deployments // From 32c69f4d0fc411b64a461d3491e602e9a8eb6a83 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 13:05:06 +0200 Subject: [PATCH 4/6] Update to latest --- .../.test/common/deploy.test.bicep | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep b/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep index ad35b83ebf..226f6e90f5 100644 --- a/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep @@ -3,14 +3,14 @@ targetScope = 'subscription' // ========== // // Parameters // // ========== // -@description('Optional. The name of the resource group to deploy for a testing purposes') +@description('Optional. The name of the resource group to deploy for a testing purposes.') @maxLength(90) param resourceGroupName string = 'ms.network.applicationsecuritygroups-${serviceShort}-rg' -@description('Optional. The location to deploy resources to') +@description('Optional. The location to deploy resources to.') param location string = deployment().location -@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints') +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.') param serviceShort string = 'nasgcom' // =========== // From 29f6f0435b9ab829fb7d39a554d9509c64161724 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 13:57:23 +0200 Subject: [PATCH 5/6] Update to latest --- .../Microsoft.Network/applicationSecurityGroups/readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.Network/applicationSecurityGroups/readme.md b/modules/Microsoft.Network/applicationSecurityGroups/readme.md index 0b8b0044e6..f62f289a45 100644 --- a/modules/Microsoft.Network/applicationSecurityGroups/readme.md +++ b/modules/Microsoft.Network/applicationSecurityGroups/readme.md @@ -163,10 +163,10 @@ The following module usage examples are retrieved from the content of the files ```bicep module applicationSecurityGroups './Microsoft.Network/applicationSecurityGroups/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-test-nasgdef' + name: '${uniqueString(deployment().name)}-test-nasgcom' params: { // Required parameters - name: '<>nasgdef001' + name: '<>nasgcom001' // Non-required parameters lock: 'CanNotDelete' roleAssignments: [ @@ -195,7 +195,7 @@ module applicationSecurityGroups './Microsoft.Network/applicationSecurityGroups/ "parameters": { // Required parameters "name": { - "value": "<>nasgdef001" + "value": "<>nasgcom001" }, // Non-required parameters "lock": { From a7809276ddf0ed2190c269c20dbebb4cd576b1ff Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 19 Sep 2022 00:06:43 +0200 Subject: [PATCH 6/6] Update modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep --- .../applicationSecurityGroups/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep b/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep index 226f6e90f5..3117f581df 100644 --- a/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/applicationSecurityGroups/.test/common/deploy.test.bicep @@ -3,7 +3,7 @@ targetScope = 'subscription' // ========== // // Parameters // // ========== // -@description('Optional. The name of the resource group to deploy for a testing purposes.') +@description('Optional. The name of the resource group to deploy for testing purposes.') @maxLength(90) param resourceGroupName string = 'ms.network.applicationsecuritygroups-${serviceShort}-rg'