From 7ff48d0dcc3ea81305aab57aa730c2984feba746 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 16 Sep 2022 11:40:23 +0200 Subject: [PATCH 1/5] Update Network LocalNetworkGateway to new dependency approach --- .../ms.network.localnetworkgateways.yml | 3 +- .../.test/common/dependencies.bicep | 14 +++++ .../.test/common/deploy.test.bicep | 60 ++++++++++++++++++ .../.test/min/dependencies.bicep | 14 +++++ .../.test/min/deploy.test.bicep | 49 +++++++++++++++ .../.test/parameters.json | 36 ----------- .../localNetworkGateways/readme.md | 63 +++++++++++++++++-- 7 files changed, 195 insertions(+), 44 deletions(-) create mode 100644 modules/Microsoft.Network/localNetworkGateways/.test/common/dependencies.bicep create mode 100644 modules/Microsoft.Network/localNetworkGateways/.test/common/deploy.test.bicep create mode 100644 modules/Microsoft.Network/localNetworkGateways/.test/min/dependencies.bicep create mode 100644 modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep delete mode 100644 modules/Microsoft.Network/localNetworkGateways/.test/parameters.json diff --git a/.github/workflows/ms.network.localnetworkgateways.yml b/.github/workflows/ms.network.localnetworkgateways.yml index a1c63c107e..c119a2ceb9 100644 --- a/.github/workflows/ms.network.localnetworkgateways.yml +++ b/.github/workflows/ms.network.localnetworkgateways.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/localNetworkGateways/.test/common/dependencies.bicep b/modules/Microsoft.Network/localNetworkGateways/.test/common/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.Network/localNetworkGateways/.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/localNetworkGateways/.test/common/deploy.test.bicep b/modules/Microsoft.Network/localNetworkGateways/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..358193637c --- /dev/null +++ b/modules/Microsoft.Network/localNetworkGateways/.test/common/deploy.test.bicep @@ -0,0 +1,60 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.network.localnetworkgateways-${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 = 'nlngcom' + +// =========== // +// 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' + localAddressPrefixes: [ + '192.168.1.0/24' + ] + localGatewayPublicIpAddress: '8.8.8.8' + localAsn: '65123' + localBgpPeeringAddress: '192.168.1.5' + lock: 'CanNotDelete' + roleAssignments: [ + { + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + roleDefinitionIdOrName: 'Reader' + } + ] + } +} diff --git a/modules/Microsoft.Network/localNetworkGateways/.test/min/dependencies.bicep b/modules/Microsoft.Network/localNetworkGateways/.test/min/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.Network/localNetworkGateways/.test/min/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/localNetworkGateways/.test/min/deploy.test.bicep b/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..5ac39eb32c --- /dev/null +++ b/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep @@ -0,0 +1,49 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.network.localnetworkgateways-${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 = 'nlngmin' + +// =========== // +// 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' + localAddressPrefixes: [ + '192.168.1.0/24' + ] + localGatewayPublicIpAddress: '8.8.8.8' + } +} diff --git a/modules/Microsoft.Network/localNetworkGateways/.test/parameters.json b/modules/Microsoft.Network/localNetworkGateways/.test/parameters.json deleted file mode 100644 index f2d289d373..0000000000 --- a/modules/Microsoft.Network/localNetworkGateways/.test/parameters.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-lng-x-001" - }, - "lock": { - "value": "CanNotDelete" - }, - "localAddressPrefixes": { - "value": [ - "192.168.1.0/24" - ] - }, - "localGatewayPublicIpAddress": { - "value": "8.8.8.8" - }, - "localAsn": { - "value": "65123" - }, - "localBgpPeeringAddress": { - "value": "192.168.1.5" - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - } - } -} diff --git a/modules/Microsoft.Network/localNetworkGateways/readme.md b/modules/Microsoft.Network/localNetworkGateways/readme.md index 6a078ec77e..4a7e037ae1 100644 --- a/modules/Microsoft.Network/localNetworkGateways/readme.md +++ b/modules/Microsoft.Network/localNetworkGateways/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: Parameters

+

Example 1: Common

@@ -169,14 +169,14 @@ The following module usage examples are retrieved from the content of the files ```bicep module localNetworkGateways './Microsoft.Network/localNetworkGateways/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-LocalNetworkGateways' + name: '${uniqueString(deployment().name)}-test-nlngcom' params: { // Required parameters localAddressPrefixes: [ '192.168.1.0/24' ] localGatewayPublicIpAddress: '8.8.8.8' - name: '<>-az-lng-x-001' + name: '<>nlngcom001' // Non-required parameters localAsn: '65123' localBgpPeeringAddress: '192.168.1.5' @@ -184,7 +184,7 @@ module localNetworkGateways './Microsoft.Network/localNetworkGateways/deploy.bic roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } @@ -215,7 +215,7 @@ module localNetworkGateways './Microsoft.Network/localNetworkGateways/deploy.bic "value": "8.8.8.8" }, "name": { - "value": "<>-az-lng-x-001" + "value": "<>nlngcom001" }, // Non-required parameters "localAsn": { @@ -231,7 +231,7 @@ module localNetworkGateways './Microsoft.Network/localNetworkGateways/deploy.bic "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -243,3 +243,54 @@ module localNetworkGateways './Microsoft.Network/localNetworkGateways/deploy.bic

+ +

Example 2: Min

+ +
+ +via Bicep module + +```bicep +module localNetworkGateways './Microsoft.Network/localNetworkGateways/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-nlngmin' + params: { + // Required parameters + localAddressPrefixes: [ + '192.168.1.0/24' + ] + localGatewayPublicIpAddress: '8.8.8.8' + name: '<>nlngmin001' + } +} +``` + +
+

+ +

+ +via JSON Parameter file + +```json +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + // Required parameters + "localAddressPrefixes": { + "value": [ + "192.168.1.0/24" + ] + }, + "localGatewayPublicIpAddress": { + "value": "8.8.8.8" + }, + "name": { + "value": "<>nlngmin001" + } + } +} +``` + +
+

From 962067ba98243626363667fe61c33bc2b2744046 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Sun, 18 Sep 2022 23:45:05 +0200 Subject: [PATCH 2/5] Update modules/Microsoft.Network/localNetworkGateways/.test/common/deploy.test.bicep --- .../localNetworkGateways/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/localNetworkGateways/.test/common/deploy.test.bicep b/modules/Microsoft.Network/localNetworkGateways/.test/common/deploy.test.bicep index 358193637c..c43354358c 100644 --- a/modules/Microsoft.Network/localNetworkGateways/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/localNetworkGateways/.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.localnetworkgateways-${serviceShort}-rg' From 57fca67abefb2e4427d94495cb6ea848ff5cf270 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Sun, 18 Sep 2022 23:45:26 +0200 Subject: [PATCH 3/5] Update modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep --- .../localNetworkGateways/.test/min/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep b/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep index 5ac39eb32c..d7b3096926 100644 --- a/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/localNetworkGateways/.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.localnetworkgateways-${serviceShort}-rg' From 141897e0ed3152172aad5ca06b17b9f3bc7a42bf Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 5 Oct 2022 21:15:12 +0200 Subject: [PATCH 4/5] Update to latest --- .../localNetworkGateways/.test/common/deploy.test.bicep | 6 +++--- .../localNetworkGateways/.test/min/deploy.test.bicep | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/Microsoft.Network/localNetworkGateways/.test/common/deploy.test.bicep b/modules/Microsoft.Network/localNetworkGateways/.test/common/deploy.test.bicep index c43354358c..6e2430c2a1 100644 --- a/modules/Microsoft.Network/localNetworkGateways/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/localNetworkGateways/.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.localnetworkgateways-${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 = 'nlngcom' // =========== // diff --git a/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep b/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep index d7b3096926..0ad5009614 100644 --- a/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/localNetworkGateways/.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.localnetworkgateways-${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 = 'nlngmin' // =========== // From 2c053c05fd6fb72114a0d67f8d97c9f785f96497 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Mon, 10 Oct 2022 19:45:24 +0200 Subject: [PATCH 5/5] Cleanup --- .../.test/min/dependencies.bicep | 14 -------------- .../.test/min/deploy.test.bicep | 8 -------- 2 files changed, 22 deletions(-) delete mode 100644 modules/Microsoft.Network/localNetworkGateways/.test/min/dependencies.bicep diff --git a/modules/Microsoft.Network/localNetworkGateways/.test/min/dependencies.bicep b/modules/Microsoft.Network/localNetworkGateways/.test/min/dependencies.bicep deleted file mode 100644 index 7371d4437b..0000000000 --- a/modules/Microsoft.Network/localNetworkGateways/.test/min/dependencies.bicep +++ /dev/null @@ -1,14 +0,0 @@ -@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/localNetworkGateways/.test/min/deploy.test.bicep b/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep index 0ad5009614..73fb56cf0e 100644 --- a/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/localNetworkGateways/.test/min/deploy.test.bicep @@ -24,14 +24,6 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { location: location } -module resourceGroupResources 'dependencies.bicep' = { - scope: resourceGroup - name: '${uniqueString(deployment().name, location)}-paramNested' - params: { - managedIdentityName: 'dep-<>-msi-${serviceShort}' - } -} - // ============== // // Test Execution // // ============== //