From 615d27bcd463777989b59b670b486d1ddce0bd3f Mon Sep 17 00:00:00 2001 From: MrMCake Date: Sun, 18 Sep 2022 12:58:04 +0200 Subject: [PATCH 1/4] Updated Network DDOS Proction Plans to new dependencies approach --- .../ms.network.ddosprotectionplans.yml | 3 +- .../.test/common/dependencies.bicep | 14 +++++ .../.test/common/deploy.test.bicep | 54 +++++++++++++++++++ .../.test/min/deploy.test.bicep | 37 +++++++++++++ .../ddosProtectionPlans/.test/parameters.json | 22 -------- .../ddosProtectionPlans/readme.md | 49 ++++++++++++++--- 6 files changed, 149 insertions(+), 30 deletions(-) create mode 100644 modules/Microsoft.Network/ddosProtectionPlans/.test/common/dependencies.bicep create mode 100644 modules/Microsoft.Network/ddosProtectionPlans/.test/common/deploy.test.bicep create mode 100644 modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep delete mode 100644 modules/Microsoft.Network/ddosProtectionPlans/.test/parameters.json diff --git a/.github/workflows/ms.network.ddosprotectionplans.yml b/.github/workflows/ms.network.ddosprotectionplans.yml index fae4890183..047e825a8f 100644 --- a/.github/workflows/ms.network.ddosprotectionplans.yml +++ b/.github/workflows/ms.network.ddosprotectionplans.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/ddosProtectionPlans/.test/common/dependencies.bicep b/modules/Microsoft.Network/ddosProtectionPlans/.test/common/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.Network/ddosProtectionPlans/.test/common/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/ddosProtectionPlans/.test/common/deploy.test.bicep b/modules/Microsoft.Network/ddosProtectionPlans/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..cb77bea978 --- /dev/null +++ b/modules/Microsoft.Network/ddosProtectionPlans/.test/common/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.ddosprotectionplans-${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 = 'ndppcom' + +// =========== // +// 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/ddosProtectionPlans/.test/min/deploy.test.bicep b/modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..47e252468c --- /dev/null +++ b/modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep @@ -0,0 +1,37 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.network.ddosprotectionplans-${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 = 'ndppmin' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: '<>${serviceShort}001' + } +} diff --git a/modules/Microsoft.Network/ddosProtectionPlans/.test/parameters.json b/modules/Microsoft.Network/ddosProtectionPlans/.test/parameters.json deleted file mode 100644 index fe639affc6..0000000000 --- a/modules/Microsoft.Network/ddosProtectionPlans/.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-ddos-x-001" - }, - "lock": { - "value": "CanNotDelete" - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - } - } -} diff --git a/modules/Microsoft.Network/ddosProtectionPlans/readme.md b/modules/Microsoft.Network/ddosProtectionPlans/readme.md index 55fe2f2f01..6c504024d9 100644 --- a/modules/Microsoft.Network/ddosProtectionPlans/readme.md +++ b/modules/Microsoft.Network/ddosProtectionPlans/readme.md @@ -155,7 +155,7 @@ The following module usage examples are retrieved from the content of the files >**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order. -

Example 1: Parameters

+

Example 1: Common

@@ -163,16 +163,16 @@ The following module usage examples are retrieved from the content of the files ```bicep module ddosProtectionPlans './Microsoft.Network/ddosProtectionPlans/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-DdosProtectionPlans' + name: '${uniqueString(deployment().name)}-test-ndppcom' params: { // Required parameters - name: '<>-az-ddos-x-001' + name: '<>ndppcom001' // Non-required parameters lock: 'CanNotDelete' roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } @@ -195,7 +195,7 @@ module ddosProtectionPlans './Microsoft.Network/ddosProtectionPlans/deploy.bicep "parameters": { // Required parameters "name": { - "value": "<>-az-ddos-x-001" + "value": "<>ndppcom001" }, // Non-required parameters "lock": { @@ -205,7 +205,7 @@ module ddosProtectionPlans './Microsoft.Network/ddosProtectionPlans/deploy.bicep "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -217,3 +217,40 @@ module ddosProtectionPlans './Microsoft.Network/ddosProtectionPlans/deploy.bicep

+ +

Example 2: Min

+ +
+ +via Bicep module + +```bicep +module ddosProtectionPlans './Microsoft.Network/ddosProtectionPlans/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-ndppmin' + params: { + name: '<>ndppmin001' + } +} +``` + +
+

+ +

+ +via JSON Parameter file + +```json +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "name": { + "value": "<>ndppmin001" + } + } +} +``` + +
+

From 7c22e71ea3ac086de371f35792b6cf1ab7436078 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Sun, 18 Sep 2022 23:40:45 +0200 Subject: [PATCH 2/4] Update modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep --- .../ddosProtectionPlans/.test/min/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep b/modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep index 47e252468c..6526c2b1c8 100644 --- a/modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/ddosProtectionPlans/.test/min/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.ddosprotectionplans-${serviceShort}-rg' From a5b1000c15530927a733f3b2a934aa3c91d247aa Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Sun, 18 Sep 2022 23:40:52 +0200 Subject: [PATCH 3/4] Update modules/Microsoft.Network/ddosProtectionPlans/.test/common/deploy.test.bicep --- .../ddosProtectionPlans/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/ddosProtectionPlans/.test/common/deploy.test.bicep b/modules/Microsoft.Network/ddosProtectionPlans/.test/common/deploy.test.bicep index cb77bea978..80bcd0bcd3 100644 --- a/modules/Microsoft.Network/ddosProtectionPlans/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/ddosProtectionPlans/.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.ddosprotectionplans-${serviceShort}-rg' From 92f4f1793f1cd5d16503745be1fe1aa201ceeaf4 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 5 Oct 2022 21:05:01 +0200 Subject: [PATCH 4/4] Update to latest --- .../ddosProtectionPlans/.test/common/deploy.test.bicep | 6 +++--- .../ddosProtectionPlans/.test/min/deploy.test.bicep | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/Microsoft.Network/ddosProtectionPlans/.test/common/deploy.test.bicep b/modules/Microsoft.Network/ddosProtectionPlans/.test/common/deploy.test.bicep index 80bcd0bcd3..e0320e51b1 100644 --- a/modules/Microsoft.Network/ddosProtectionPlans/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/ddosProtectionPlans/.test/common/deploy.test.bicep @@ -3,14 +3,14 @@ targetScope = 'subscription' // ========== // // Parameters // // ========== // -@description('Optional. The name of the resource group to deploy for testing purposes') +@description('Optional. The name of the resource group to deploy for testing purposes.') @maxLength(90) param resourceGroupName string = 'ms.network.ddosprotectionplans-${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 = 'ndppcom' // =========== // diff --git a/modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep b/modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep index 6526c2b1c8..6501c5cd3b 100644 --- a/modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/ddosProtectionPlans/.test/min/deploy.test.bicep @@ -3,14 +3,14 @@ targetScope = 'subscription' // ========== // // Parameters // // ========== // -@description('Optional. The name of the resource group to deploy for testing purposes') +@description('Optional. The name of the resource group to deploy for testing purposes.') @maxLength(90) param resourceGroupName string = 'ms.network.ddosprotectionplans-${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 = 'ndppmin' // =========== //