From 63a3ee959d02c73f0a20beb0c69653c4e7fb4980 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 16 Sep 2022 11:46:09 +0200 Subject: [PATCH 1/4] Update Network IP Groups to new dependency approach --- .github/workflows/ms.network.ipgroups.yml | 3 +- .../ipGroups/.test/common/dependencies.bicep | 14 +++++ .../ipGroups/.test/common/deploy.test.bicep | 58 +++++++++++++++++++ .../ipGroups/.test/min/deploy.test.bicep | 37 ++++++++++++ .../ipGroups/.test/parameters.json | 28 --------- modules/Microsoft.Network/ipGroups/readme.md | 49 ++++++++++++++-- 6 files changed, 153 insertions(+), 36 deletions(-) create mode 100644 modules/Microsoft.Network/ipGroups/.test/common/dependencies.bicep create mode 100644 modules/Microsoft.Network/ipGroups/.test/common/deploy.test.bicep create mode 100644 modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep delete mode 100644 modules/Microsoft.Network/ipGroups/.test/parameters.json diff --git a/.github/workflows/ms.network.ipgroups.yml b/.github/workflows/ms.network.ipgroups.yml index 7eb62ad396..bc550189e9 100644 --- a/.github/workflows/ms.network.ipgroups.yml +++ b/.github/workflows/ms.network.ipgroups.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/ipGroups/.test/common/dependencies.bicep b/modules/Microsoft.Network/ipGroups/.test/common/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.Network/ipGroups/.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/ipGroups/.test/common/deploy.test.bicep b/modules/Microsoft.Network/ipGroups/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..113d877e97 --- /dev/null +++ b/modules/Microsoft.Network/ipGroups/.test/common/deploy.test.bicep @@ -0,0 +1,58 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.network.ipgroups-${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 = 'nigcom' + +// =========== // +// 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' + ipAddresses: [ + '10.0.0.1' + '10.0.0.2' + ] + lock: 'CanNotDelete' + roleAssignments: [ + { + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + roleDefinitionIdOrName: 'Reader' + } + ] + } +} diff --git a/modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep b/modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..9b6f81cebf --- /dev/null +++ b/modules/Microsoft.Network/ipGroups/.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.ipgroups-${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 = 'nigmin' + +// =========== // +// 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/ipGroups/.test/parameters.json b/modules/Microsoft.Network/ipGroups/.test/parameters.json deleted file mode 100644 index b30fd0db80..0000000000 --- a/modules/Microsoft.Network/ipGroups/.test/parameters.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "iacsGroup-servers" - }, - "lock": { - "value": "CanNotDelete" - }, - "ipAddresses": { - "value": [ - "10.0.0.1", - "10.0.0.2" - ] - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - } - } -} diff --git a/modules/Microsoft.Network/ipGroups/readme.md b/modules/Microsoft.Network/ipGroups/readme.md index 799e5c7e15..c8322679c8 100644 --- a/modules/Microsoft.Network/ipGroups/readme.md +++ b/modules/Microsoft.Network/ipGroups/readme.md @@ -156,7 +156,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

@@ -164,10 +164,10 @@ The following module usage examples are retrieved from the content of the files ```bicep module ipGroups './Microsoft.Network/ipGroups/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-IpGroups' + name: '${uniqueString(deployment().name)}-test-nigcom' params: { // Required parameters - name: 'iacsGroup-servers' + name: '<>nigcom001' // Non-required parameters ipAddresses: [ '10.0.0.1' @@ -177,7 +177,7 @@ module ipGroups './Microsoft.Network/ipGroups/deploy.bicep' = { roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } @@ -200,7 +200,7 @@ module ipGroups './Microsoft.Network/ipGroups/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "iacsGroup-servers" + "value": "<>nigcom001" }, // Non-required parameters "ipAddresses": { @@ -216,7 +216,7 @@ module ipGroups './Microsoft.Network/ipGroups/deploy.bicep' = { "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -228,3 +228,40 @@ module ipGroups './Microsoft.Network/ipGroups/deploy.bicep' = {

+ +

Example 2: Min

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

+ +

+ +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": "<>nigmin001" + } + } +} +``` + +
+

From 170f519d4eaf436f2d8bccc73b6ebd53c47c0cda Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Sun, 18 Sep 2022 23:44:02 +0200 Subject: [PATCH 2/4] Update modules/Microsoft.Network/ipGroups/.test/common/deploy.test.bicep --- .../Microsoft.Network/ipGroups/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/ipGroups/.test/common/deploy.test.bicep b/modules/Microsoft.Network/ipGroups/.test/common/deploy.test.bicep index 113d877e97..2de85d25a1 100644 --- a/modules/Microsoft.Network/ipGroups/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/ipGroups/.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.ipgroups-${serviceShort}-rg' From 38134d696051d48beb8ed69bdf29033438df2e9c Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Sun, 18 Sep 2022 23:44:20 +0200 Subject: [PATCH 3/4] Update modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep --- modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep b/modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep index 9b6f81cebf..55c3f72607 100644 --- a/modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/ipGroups/.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.ipgroups-${serviceShort}-rg' From c0f86e3c080d3b876d554c9d397a641a6516d086 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 5 Oct 2022 21:12:38 +0200 Subject: [PATCH 4/4] Update to latest --- .../ipGroups/.test/common/deploy.test.bicep | 6 +++--- .../Microsoft.Network/ipGroups/.test/min/deploy.test.bicep | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/Microsoft.Network/ipGroups/.test/common/deploy.test.bicep b/modules/Microsoft.Network/ipGroups/.test/common/deploy.test.bicep index 2de85d25a1..c2ed33b564 100644 --- a/modules/Microsoft.Network/ipGroups/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/ipGroups/.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.ipgroups-${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 = 'nigcom' // =========== // diff --git a/modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep b/modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep index 55c3f72607..53ef1d198a 100644 --- a/modules/Microsoft.Network/ipGroups/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/ipGroups/.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.ipgroups-${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 = 'nigmin' // =========== //