From 1c92bb53ef24c3b8cada30533a6b5f53162b407e Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 15:37:24 +0200 Subject: [PATCH 1/3] Updated ManagedServices RegistrationDefinitions to new dependency approach --- ...anagedservices.registrationdefinitions.yml | 3 +- .../.test/common/deploy.test.bicep | 37 ++++++++++++ .../.test/parameters.json | 34 ----------- .../.test/rg.parameters.json | 37 ------------ .../.test/rg/dependencies.bicep | 3 + .../.test/rg/deploy.test.bicep | 56 +++++++++++++++++++ .../registrationDefinitions/readme.md | 18 +++--- 7 files changed, 106 insertions(+), 82 deletions(-) create mode 100644 modules/Microsoft.ManagedServices/registrationDefinitions/.test/common/deploy.test.bicep delete mode 100644 modules/Microsoft.ManagedServices/registrationDefinitions/.test/parameters.json delete mode 100644 modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg.parameters.json create mode 100644 modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/dependencies.bicep create mode 100644 modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep diff --git a/.github/workflows/ms.managedservices.registrationdefinitions.yml b/.github/workflows/ms.managedservices.registrationdefinitions.yml index db7aea3412..939eb5c7dc 100644 --- a/.github/workflows/ms.managedservices.registrationdefinitions.yml +++ b/.github/workflows/ms.managedservices.registrationdefinitions.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.ManagedServices/registrationDefinitions/.test/common/deploy.test.bicep b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..78775e8263 --- /dev/null +++ b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/common/deploy.test.bicep @@ -0,0 +1,37 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@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 = 'msrdcom' + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: 'Component Validation - <>${serviceShort} Subscription assignment' + authorizations: [ + { + principalId: 'e87a249c-b53b-4685-94fe-863af522e4ee' + principalIdDisplayName: 'ResourceModules-Reader' + roleDefinitionId: 'acdd72a7-3385-48ef-bd42-f606fba81ae7' + } + { + principalId: 'e2f126a7-136e-443f-b39f-f73ddfd146b1' + principalIdDisplayName: 'ResourceModules-Contributor' + roleDefinitionId: 'b24988ac-6180-42a0-ab88-20f7382dd24c' + } + { + principalId: '87813317-fb25-4c76-91fe-783af429d109' + principalIdDisplayName: 'ResourceModules-LHManagement' + roleDefinitionId: '91c1777a-f3dc-4fae-b103-61d183457e46' + } + ] + managedByTenantId: '195ee85d-2f10-4764-8352-a3c99aa772fb' + registrationDescription: 'Managed by Lighthouse' + } +} diff --git a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/parameters.json b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/parameters.json deleted file mode 100644 index 8fc6fc1cc9..0000000000 --- a/modules/Microsoft.ManagedServices/registrationDefinitions/.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": "Component Validation - Subscription assignment" - }, - "registrationDescription": { - "value": "Managed by Lighthouse" - }, - "managedByTenantId": { - "value": "195ee85d-2f10-4764-8352-a3c99aa772fb" - }, - "authorizations": { - "value": [ - { - "principalId": "e87a249c-b53b-4685-94fe-863af522e4ee", - "principalIdDisplayName": "ResourceModules-Reader", - "roleDefinitionId": "acdd72a7-3385-48ef-bd42-f606fba81ae7" - }, - { - "principalId": "e2f126a7-136e-443f-b39f-f73ddfd146b1", - "principalIdDisplayName": "ResourceModules-Contributor", - "roleDefinitionId": "b24988ac-6180-42a0-ab88-20f7382dd24c" - }, - { - "principalId": "87813317-fb25-4c76-91fe-783af429d109", - "principalIdDisplayName": "ResourceModules-LHManagement", - "roleDefinitionId": "91c1777a-f3dc-4fae-b103-61d183457e46" - } - ] - } - } -} diff --git a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg.parameters.json b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg.parameters.json deleted file mode 100644 index 5e21414369..0000000000 --- a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg.parameters.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "Component Validation - Resource group assignment" - }, - "registrationDescription": { - "value": "Managed by Lighthouse" - }, - "managedByTenantId": { - "value": "195ee85d-2f10-4764-8352-a3c99aa772fb" - }, - "resourceGroupName": { - "value": "validation-rg" - }, - "authorizations": { - "value": [ - { - "principalId": "e87a249c-b53b-4685-94fe-863af522e4ee", - "principalIdDisplayName": "ResourceModules-Reader", - "roleDefinitionId": "acdd72a7-3385-48ef-bd42-f606fba81ae7" - }, - { - "principalId": "e2f126a7-136e-443f-b39f-f73ddfd146b1", - "principalIdDisplayName": "ResourceModules-Contributor", - "roleDefinitionId": "b24988ac-6180-42a0-ab88-20f7382dd24c" - }, - { - "principalId": "87813317-fb25-4c76-91fe-783af429d109", - "principalIdDisplayName": "ResourceModules-LHManagement", - "roleDefinitionId": "91c1777a-f3dc-4fae-b103-61d183457e46" - } - ] - } - } -} diff --git a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/dependencies.bicep b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/dependencies.bicep new file mode 100644 index 0000000000..e0a19befb3 --- /dev/null +++ b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/dependencies.bicep @@ -0,0 +1,3 @@ +@description('Optional. The location to deploy to.') +param location string = resourceGroup().location + diff --git a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep new file mode 100644 index 0000000000..d1d1a189d5 --- /dev/null +++ b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep @@ -0,0 +1,56 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.managedservices.registrationdefinitions-${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 = 'msrdrg' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: 'Component Validation - <>${serviceShort} Resource group assignment' + authorizations: [ + { + principalId: 'e87a249c-b53b-4685-94fe-863af522e4ee' + principalIdDisplayName: 'ResourceModules-Reader' + roleDefinitionId: 'acdd72a7-3385-48ef-bd42-f606fba81ae7' + } + { + principalId: 'e2f126a7-136e-443f-b39f-f73ddfd146b1' + principalIdDisplayName: 'ResourceModules-Contributor' + roleDefinitionId: 'b24988ac-6180-42a0-ab88-20f7382dd24c' + } + { + principalId: '87813317-fb25-4c76-91fe-783af429d109' + principalIdDisplayName: 'ResourceModules-LHManagement' + roleDefinitionId: '91c1777a-f3dc-4fae-b103-61d183457e46' + } + ] + managedByTenantId: '195ee85d-2f10-4764-8352-a3c99aa772fb' + registrationDescription: 'Managed by Lighthouse' + resourceGroupName: resourceGroup.name + } +} diff --git a/modules/Microsoft.ManagedServices/registrationDefinitions/readme.md b/modules/Microsoft.ManagedServices/registrationDefinitions/readme.md index 93f7080a60..925aaa824e 100644 --- a/modules/Microsoft.ManagedServices/registrationDefinitions/readme.md +++ b/modules/Microsoft.ManagedServices/registrationDefinitions/readme.md @@ -175,7 +175,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

@@ -183,7 +183,7 @@ The following module usage examples are retrieved from the content of the files ```bicep module registrationDefinitions './Microsoft.ManagedServices/registrationDefinitions/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-RegistrationDefinitions' + name: '${uniqueString(deployment().name)}-test-msrdcom' params: { // Required parameters authorizations: [ @@ -204,7 +204,7 @@ module registrationDefinitions './Microsoft.ManagedServices/registrationDefiniti } ] managedByTenantId: '195ee85d-2f10-4764-8352-a3c99aa772fb' - name: 'Component Validation - Subscription assignment' + name: 'Component Validation - <>msrdcom Subscription assignment' registrationDescription: 'Managed by Lighthouse' } } @@ -246,7 +246,7 @@ module registrationDefinitions './Microsoft.ManagedServices/registrationDefiniti "value": "195ee85d-2f10-4764-8352-a3c99aa772fb" }, "name": { - "value": "Component Validation - Subscription assignment" + "value": "Component Validation - <>msrdcom Subscription assignment" }, "registrationDescription": { "value": "Managed by Lighthouse" @@ -266,7 +266,7 @@ module registrationDefinitions './Microsoft.ManagedServices/registrationDefiniti ```bicep module registrationDefinitions './Microsoft.ManagedServices/registrationDefinitions/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-RegistrationDefinitions' + name: '${uniqueString(deployment().name)}-test-msrdrg' params: { // Required parameters authorizations: [ @@ -287,10 +287,10 @@ module registrationDefinitions './Microsoft.ManagedServices/registrationDefiniti } ] managedByTenantId: '195ee85d-2f10-4764-8352-a3c99aa772fb' - name: 'Component Validation - Resource group assignment' + name: 'Component Validation - <>msrdrg Resource group assignment' registrationDescription: 'Managed by Lighthouse' // Non-required parameters - resourceGroupName: 'validation-rg' + resourceGroupName: '' } } ``` @@ -331,14 +331,14 @@ module registrationDefinitions './Microsoft.ManagedServices/registrationDefiniti "value": "195ee85d-2f10-4764-8352-a3c99aa772fb" }, "name": { - "value": "Component Validation - Resource group assignment" + "value": "Component Validation - <>msrdrg Resource group assignment" }, "registrationDescription": { "value": "Managed by Lighthouse" }, // Non-required parameters "resourceGroupName": { - "value": "validation-rg" + "value": "" } } } From 31bddd99709725069a895697ef7408804ee3f9b7 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Sun, 18 Sep 2022 23:51:18 +0200 Subject: [PATCH 2/3] Update modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep --- .../registrationDefinitions/.test/rg/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep index d1d1a189d5..10d1fcf761 100644 --- a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep +++ b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/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.managedservices.registrationdefinitions-${serviceShort}-rg' From 67473a978cbb6f27c6a5009d1b9412151eb56921 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 5 Oct 2022 20:15:16 +0200 Subject: [PATCH 3/3] Update to latest --- .../registrationDefinitions/.test/common/deploy.test.bicep | 2 +- .../registrationDefinitions/.test/rg/dependencies.bicep | 3 --- .../registrationDefinitions/.test/rg/deploy.test.bicep | 6 +++--- 3 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/dependencies.bicep diff --git a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/common/deploy.test.bicep b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/common/deploy.test.bicep index 78775e8263..e6c6614210 100644 --- a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/common/deploy.test.bicep +++ b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/common/deploy.test.bicep @@ -3,7 +3,7 @@ targetScope = 'subscription' // ========== // // Parameters // // ========== // -@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 = 'msrdcom' // ============== // diff --git a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/dependencies.bicep b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/dependencies.bicep deleted file mode 100644 index e0a19befb3..0000000000 --- a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/dependencies.bicep +++ /dev/null @@ -1,3 +0,0 @@ -@description('Optional. The location to deploy to.') -param location string = resourceGroup().location - diff --git a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep index 10d1fcf761..ae8722c4cf 100644 --- a/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/deploy.test.bicep +++ b/modules/Microsoft.ManagedServices/registrationDefinitions/.test/rg/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.managedservices.registrationdefinitions-${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 = 'msrdrg' // =========== //