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/common/dependencies.bicep b/modules/Microsoft.Network/virtualWans/.test/common/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.Network/virtualWans/.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/virtualWans/.test/common/deploy.test.bicep b/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..caab3b6679 --- /dev/null +++ b/modules/Microsoft.Network/virtualWans/.test/common/deploy.test.bicep @@ -0,0 +1,58 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for 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 = 'nvwcom' + +// =========== // +// 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..93e32f9632 --- /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 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 15caaa96a5..3f87b89ce1 100644 --- a/modules/Microsoft.Network/virtualWans/readme.md +++ b/modules/Microsoft.Network/virtualWans/readme.md @@ -161,7 +161,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: Min

+

Example 1: Common

@@ -169,47 +169,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-nvwcom' params: { // Required parameters - name: '<>-az-vw-x-001' + name: '<>nvwcom001' // Non-required parameters allowBranchToBranchTraffic: true allowVnetToVnetTraffic: true @@ -218,7 +181,7 @@ module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = { roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } @@ -242,7 +205,7 @@ module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>-az-vw-x-001" + "value": "<>nvwcom001" }, // Non-required parameters "allowBranchToBranchTraffic": { @@ -261,7 +224,7 @@ module virtualWans './Microsoft.Network/virtualWans/deploy.bicep' = { "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -276,3 +239,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" + } + } +} +``` + +
+