From b2ec1c80199749a82c003aca15f4b6f7ed5f8238 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Sun, 4 Sep 2022 13:51:59 +0200 Subject: [PATCH 1/6] Updated Managed Identity to new dependency approach --- ...managedidentity.userassignedidentities.yml | 3 +- .../.test/default/dependencies.bicep | 14 +++++ .../.test/default/deploy.test.bicep | 54 +++++++++++++++++++ .../.test/parameters.json | 22 -------- .../userAssignedIdentities/readme.md | 12 ++--- 5 files changed, 75 insertions(+), 30 deletions(-) create mode 100644 modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/default/dependencies.bicep create mode 100644 modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/default/deploy.test.bicep delete mode 100644 modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/parameters.json diff --git a/.github/workflows/ms.managedidentity.userassignedidentities.yml b/.github/workflows/ms.managedidentity.userassignedidentities.yml index 42e2d6a764..e05d2c07fb 100644 --- a/.github/workflows/ms.managedidentity.userassignedidentities.yml +++ b/.github/workflows/ms.managedidentity.userassignedidentities.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.ManagedIdentity/userAssignedIdentities/.test/default/dependencies.bicep b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/default/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.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.ManagedIdentity/userAssignedIdentities/.test/default/deploy.test.bicep b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/default/deploy.test.bicep new file mode 100644 index 0000000000..e0551047f0 --- /dev/null +++ b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/default/deploy.test.bicep @@ -0,0 +1,54 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.managedidentity.userassignedidentities-${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 = 'miuaidef' + +// =========== // +// 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' + lock: 'CanNotDelete' + roleAssignments: [ + { + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + roleDefinitionIdOrName: 'Reader' + } + ] + } +} diff --git a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/parameters.json b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/parameters.json deleted file mode 100644 index d76c001bb1..0000000000 --- a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/parameters.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-msi-x-001" - }, - "lock": { - "value": "CanNotDelete" - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - } - } -} diff --git a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md index 59d3ada31f..24972a0af7 100644 --- a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md +++ b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md @@ -151,7 +151,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: Parameters

+

Example 1: Default

@@ -159,14 +159,14 @@ The following module usage examples are retrieved from the content of the files ```bicep module userAssignedIdentities './Microsoft.ManagedIdentity/userAssignedIdentities/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-UserAssignedIdentities' + name: '${uniqueString(deployment().name)}-test-miuaidef' params: { lock: 'CanNotDelete' - name: '<>-az-msi-x-001' + name: '<>miuaidef001' roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } @@ -191,13 +191,13 @@ module userAssignedIdentities './Microsoft.ManagedIdentity/userAssignedIdentitie "value": "CanNotDelete" }, "name": { - "value": "<>-az-msi-x-001" + "value": "<>miuaidef001" }, "roleAssignments": { "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } From 4dd23bab187b962c39c6df923cd74cc5e56bed9e Mon Sep 17 00:00:00 2001 From: MrMCake Date: Thu, 8 Sep 2022 19:10:09 +0200 Subject: [PATCH 2/6] Updated folder default to common. --- .../.test/{default => common}/dependencies.bicep | 0 .../.test/{default => common}/deploy.test.bicep | 0 .../Microsoft.ManagedIdentity/userAssignedIdentities/readme.md | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/{default => common}/dependencies.bicep (100%) rename modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/{default => common}/deploy.test.bicep (100%) diff --git a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/default/dependencies.bicep b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/dependencies.bicep similarity index 100% rename from modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/default/dependencies.bicep rename to modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/dependencies.bicep diff --git a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/default/deploy.test.bicep b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep similarity index 100% rename from modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/default/deploy.test.bicep rename to modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep diff --git a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md index 24972a0af7..98e0c80bf7 100644 --- a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md +++ b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md @@ -151,7 +151,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 d91598d94b1b0951e9d06781ad91dada23347909 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 12:51:12 +0200 Subject: [PATCH 3/6] Update to latest --- .../userAssignedIdentities/.test/common/deploy.test.bicep | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep index e0551047f0..34c82895ff 100644 --- a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep +++ b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep @@ -10,8 +10,8 @@ param resourceGroupName string = 'ms.managedidentity.userassignedidentities-${se @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 = 'miuaidef' +@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 = 'miuaicom' // =========== // // Deployments // From dff51abeb43e365449a5d53b19f2ab6903eba1c2 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 13:04:12 +0200 Subject: [PATCH 4/6] Update to latest --- .../userAssignedIdentities/.test/common/deploy.test.bicep | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep index 34c82895ff..b77720116c 100644 --- a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep +++ b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.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.managedidentity.userassignedidentities-${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 = 'miuaicom' // =========== // From 6112e77bd412f399bc3befc199859b4b6c22d3bd Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 13:53:29 +0200 Subject: [PATCH 5/6] Update to latest --- .../userAssignedIdentities/readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md index 8b4fbac312..3784e1e48d 100644 --- a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md +++ b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/readme.md @@ -160,10 +160,10 @@ The following module usage examples are retrieved from the content of the files ```bicep module userAssignedIdentities './Microsoft.ManagedIdentity/userAssignedIdentities/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-test-miuaidef' + name: '${uniqueString(deployment().name)}-test-miuaicom' params: { lock: 'CanNotDelete' - name: '<>miuaidef001' + name: '<>miuaicom001' roleAssignments: [ { principalIds: [ @@ -192,7 +192,7 @@ module userAssignedIdentities './Microsoft.ManagedIdentity/userAssignedIdentitie "value": "CanNotDelete" }, "name": { - "value": "<>miuaidef001" + "value": "<>miuaicom001" }, "roleAssignments": { "value": [ From 46eeb68ed4e033e28327abfeb1324d8c3f32cd30 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 19 Sep 2022 08:11:45 +0200 Subject: [PATCH 6/6] Update modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep --- .../userAssignedIdentities/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep index b77720116c..8b675f9088 100644 --- a/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.test/common/deploy.test.bicep +++ b/modules/Microsoft.ManagedIdentity/userAssignedIdentities/.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.managedidentity.userassignedidentities-${serviceShort}-rg'