From 9da21ca07081957b5c18eddedb56223fda0bb51e Mon Sep 17 00:00:00 2001 From: MrMCake Date: Sun, 4 Sep 2022 14:37:51 +0200 Subject: [PATCH 1/7] Updated VirtualWAN to new dependency approach --- .github/workflows/ms.network.virtualwans.yml | 3 +- .../.test/default/dependencies.bicep | 14 +++ .../.test/default/deploy.test.bicep | 58 +++++++++++++ .../virtualWans/.test/min.parameters.json | 9 -- .../virtualWans/.test/min/deploy.test.bicep | 37 ++++++++ .../virtualWans/.test/parameters.json | 34 -------- .../Microsoft.Network/virtualWans/readme.md | 86 +++++++++---------- 7 files changed, 153 insertions(+), 88 deletions(-) create mode 100644 modules/Microsoft.Network/virtualWans/.test/default/dependencies.bicep create mode 100644 modules/Microsoft.Network/virtualWans/.test/default/deploy.test.bicep delete mode 100644 modules/Microsoft.Network/virtualWans/.test/min.parameters.json create mode 100644 modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep delete mode 100644 modules/Microsoft.Network/virtualWans/.test/parameters.json diff --git a/.github/workflows/ms.network.virtualwans.yml b/.github/workflows/ms.network.virtualwans.yml index 4183d5afcb..24e4ced6f9 100644 --- a/.github/workflows/ms.network.virtualwans.yml +++ b/.github/workflows/ms.network.virtualwans.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/virtualWans/.test/default/dependencies.bicep b/modules/Microsoft.Network/virtualWans/.test/default/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.Network/virtualWans/.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/virtualWans/.test/default/deploy.test.bicep b/modules/Microsoft.Network/virtualWans/.test/default/deploy.test.bicep new file mode 100644 index 0000000000..1f4b0b59c2 --- /dev/null +++ b/modules/Microsoft.Network/virtualWans/.test/default/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.virtualwans-${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 = 'nvwdef' + +// =========== // +// 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' + allowBranchToBranchTraffic: true + allowVnetToVnetTraffic: true + disableVpnEncryption: true + lock: 'CanNotDelete' + roleAssignments: [ + { + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + roleDefinitionIdOrName: 'Reader' + } + ] + type: 'Basic' + } +} diff --git a/modules/Microsoft.Network/virtualWans/.test/min.parameters.json b/modules/Microsoft.Network/virtualWans/.test/min.parameters.json deleted file mode 100644 index badddffd7e..0000000000 --- a/modules/Microsoft.Network/virtualWans/.test/min.parameters.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-vw-min-001" - } - } -} diff --git a/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep b/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..bc8e8d618a --- /dev/null +++ b/modules/Microsoft.Network/virtualWans/.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.virtualwans-${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 = 'nvwmin' + +// =========== // +// 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/virtualWans/.test/parameters.json b/modules/Microsoft.Network/virtualWans/.test/parameters.json deleted file mode 100644 index 15f8aa96f5..0000000000 --- a/modules/Microsoft.Network/virtualWans/.test/parameters.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-vw-x-001" - }, - "lock": { - "value": "CanNotDelete" - }, - "type": { - "value": "Basic" - }, - "allowBranchToBranchTraffic": { - "value": true - }, - "allowVnetToVnetTraffic": { - "value": true - }, - "disableVpnEncryption": { - "value": true - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - } - } -} diff --git a/modules/Microsoft.Network/virtualWans/readme.md b/modules/Microsoft.Network/virtualWans/readme.md index bb7e2a71f5..823ec59655 100644 --- a/modules/Microsoft.Network/virtualWans/readme.md +++ b/modules/Microsoft.Network/virtualWans/readme.md @@ -158,7 +158,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: Min

+

Example 1: Default

@@ -166,47 +166,10 @@ The following module usage examples are retrieved from the content of the files ```bicep module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-VirtualWans' - params: { - name: '<>-az-vw-min-001' - } -} -``` - -
-

- -

- -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": "<>-az-vw-min-001" - } - } -} -``` - -
-

- -

Example 2: Parameters

- -
- -via Bicep module - -```bicep -module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-VirtualWans' + name: '${uniqueString(deployment().name)}-test-nvwdef' params: { // Required parameters - name: '<>-az-vw-x-001' + name: '<>nvwdef001' // Non-required parameters allowBranchToBranchTraffic: true allowVnetToVnetTraffic: true @@ -215,7 +178,7 @@ module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = { roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } @@ -239,7 +202,7 @@ module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>-az-vw-x-001" + "value": "<>nvwdef001" }, // Non-required parameters "allowBranchToBranchTraffic": { @@ -258,7 +221,7 @@ module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = { "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -273,3 +236,40 @@ module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = {

+ +

Example 2: Min

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

+ +

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

From b82221ea3b750e8fb36e221315286e45ad3cb1fb Mon Sep 17 00:00:00 2001 From: MrMCake Date: Thu, 8 Sep 2022 19:16:38 +0200 Subject: [PATCH 2/7] Updated folder default to common. --- .../virtualWans/.test/{default => common}/dependencies.bicep | 0 .../virtualWans/.test/{default => common}/deploy.test.bicep | 0 modules/Microsoft.Network/virtualWans/readme.md | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename modules/Microsoft.Network/virtualWans/.test/{default => common}/dependencies.bicep (100%) rename modules/Microsoft.Network/virtualWans/.test/{default => common}/deploy.test.bicep (100%) diff --git a/modules/Microsoft.Network/virtualWans/.test/default/dependencies.bicep b/modules/Microsoft.Network/virtualWans/.test/common/dependencies.bicep similarity index 100% rename from modules/Microsoft.Network/virtualWans/.test/default/dependencies.bicep rename to modules/Microsoft.Network/virtualWans/.test/common/dependencies.bicep diff --git a/modules/Microsoft.Network/virtualWans/.test/default/deploy.test.bicep b/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep similarity index 100% rename from modules/Microsoft.Network/virtualWans/.test/default/deploy.test.bicep rename to modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep diff --git a/modules/Microsoft.Network/virtualWans/readme.md b/modules/Microsoft.Network/virtualWans/readme.md index 823ec59655..d7f58d1106 100644 --- a/modules/Microsoft.Network/virtualWans/readme.md +++ b/modules/Microsoft.Network/virtualWans/readme.md @@ -158,7 +158,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 58f74ee181c89b549b5413b1f392a15567f14e37 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 12:52:13 +0200 Subject: [PATCH 3/7] Update to latest --- .../virtualWans/.test/common/deploy.test.bicep | 4 ++-- .../Microsoft.Network/virtualWans/.test/min/deploy.test.bicep | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep b/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep index 1f4b0b59c2..643395a5fe 100644 --- a/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep @@ -10,8 +10,8 @@ param resourceGroupName string = 'ms.network.virtualwans-${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 = 'nvwdef' +@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 = 'nvwcom' // =========== // // Deployments // diff --git a/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep b/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep index bc8e8d618a..4a91bec7c6 100644 --- a/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep @@ -10,7 +10,7 @@ param resourceGroupName string = 'ms.network.virtualwans-${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') +@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 = 'nvwmin' // =========== // From 49301ba312cd4c46bcbee1d08eb04a25ab452059 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 13:05:29 +0200 Subject: [PATCH 4/7] Update to latest --- .../virtualWans/.test/common/deploy.test.bicep | 6 +++--- .../virtualWans/.test/min/deploy.test.bicep | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep b/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep index 643395a5fe..166fd01d4a 100644 --- a/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/virtualWans/.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.virtualwans-${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 = 'nvwcom' // =========== // diff --git a/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep b/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep index 4a91bec7c6..a3a4b6dda4 100644 --- a/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/virtualWans/.test/min/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.virtualwans-${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 = 'nvwmin' // =========== // From bfde350fc0691955faea7801252e24589ce5dc9e Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 13:59:28 +0200 Subject: [PATCH 5/7] Update to latest --- modules/Microsoft.Network/virtualWans/readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.Network/virtualWans/readme.md b/modules/Microsoft.Network/virtualWans/readme.md index 0d630dff0a..9b4994374c 100644 --- a/modules/Microsoft.Network/virtualWans/readme.md +++ b/modules/Microsoft.Network/virtualWans/readme.md @@ -167,10 +167,10 @@ The following module usage examples are retrieved from the content of the files ```bicep module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-test-nvwdef' + name: '${uniqueString(deployment().name)}-test-nvwcom' params: { // Required parameters - name: '<>nvwdef001' + name: '<>nvwcom001' // Non-required parameters allowBranchToBranchTraffic: true allowVnetToVnetTraffic: true @@ -203,7 +203,7 @@ module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>nvwdef001" + "value": "<>nvwcom001" }, // Non-required parameters "allowBranchToBranchTraffic": { From f0b0240e77f047a1f6b63b40c048c6833f0fa1c1 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 19 Sep 2022 08:09:41 +0200 Subject: [PATCH 6/7] Update modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep --- .../virtualWans/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep b/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep index 166fd01d4a..caab3b6679 100644 --- a/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/virtualWans/.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.virtualwans-${serviceShort}-rg' From 6465878ed34a35a5cd2e1cce5289e5acc1e43017 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 19 Sep 2022 08:10:02 +0200 Subject: [PATCH 7/7] Update modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep --- .../Microsoft.Network/virtualWans/.test/min/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep b/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep index a3a4b6dda4..93e32f9632 100644 --- a/modules/Microsoft.Network/virtualWans/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/virtualWans/.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.virtualwans-${serviceShort}-rg'