From ae636f5f3ec1f4e6b80c52052c8a674a569e005a Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Tue, 14 Jan 2025 12:06:42 +0100 Subject: [PATCH] feat: ResourceGroup - Updated UDTs to pending specs (#4108) ## Description Updated user-defined types with pending https://github.com/Azure/Azure-Verified-Modules/pull/1738 & https://github.com/Azure/bicep-registry-modules/pull/4098. ## Pipeline Reference | Pipeline | | -------- | [![avm.res.resources.resource-group](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.resources.resource-group.yml/badge.svg?branch=users%2Falsehr%2FresourceGroup_udt&event=workflow_dispatch)](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.resources.resource-group.yml) ## Type of Change - [ ] Update to CI Environment or utilities (Non-module affecting changes) - [x] Azure Verified Module updates: - [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in `version.json`: - [ ] Someone has opened a bug report issue, and I have included "Closes #{bug_report_issue_number}" in the PR description. - [ ] The bug was found by the module author, and no one has opened an issue to report it yet. - [ ] Feature update backwards compatible feature updates, and I have bumped the MINOR version in `version.json`. - [ ] Breaking changes and I have bumped the MAJOR version in `version.json`. - [ ] Update to documentation --- avm/res/resources/resource-group/README.md | 39 +---- avm/res/resources/resource-group/main.bicep | 44 +---- avm/res/resources/resource-group/main.json | 164 ++++++++++-------- .../tests/e2e/defaults/main.test.bicep | 1 - .../tests/e2e/waf-aligned/main.test.bicep | 5 - 5 files changed, 101 insertions(+), 152 deletions(-) diff --git a/avm/res/resources/resource-group/README.md b/avm/res/resources/resource-group/README.md index f2908dcd05..692f474847 100644 --- a/avm/res/resources/resource-group/README.md +++ b/avm/res/resources/resource-group/README.md @@ -8,6 +8,7 @@ This module deploys a Resource Group. - [Usage examples](#Usage-examples) - [Parameters](#Parameters) - [Outputs](#Outputs) +- [Cross-referenced modules](#Cross-referenced-modules) - [Data Collection](#Data-Collection) ## Resource Types @@ -43,10 +44,7 @@ This instance deploys the module with the minimum set of required parameters. module resourceGroup 'br/public:avm/res/resources/resource-group:' = { name: 'resourceGroupDeployment' params: { - // Required parameters name: 'avm-resources.resourcegroups-rrgmin-rg' - // Non-required parameters - location: '' } } ``` @@ -63,13 +61,8 @@ module resourceGroup 'br/public:avm/res/resources/resource-group:' = { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - // Required parameters "name": { "value": "avm-resources.resourcegroups-rrgmin-rg" - }, - // Non-required parameters - "location": { - "value": "" } } } @@ -85,10 +78,7 @@ module resourceGroup 'br/public:avm/res/resources/resource-group:' = { ```bicep-params using 'br/public:avm/res/resources/resource-group:' -// Required parameters param name = 'avm-resources.resourcegroups-rrgmin-rg' -// Non-required parameters -param location = '' ``` @@ -264,11 +254,6 @@ module resourceGroup 'br/public:avm/res/resources/resource-group:' = { // Required parameters name: 'avm-resources.resourcegroups-rrgwaf-rg' // Non-required parameters - location: '' - lock: { - kind: 'CanNotDelete' - name: 'myCustomLockName' - } tags: { Environment: 'Non-Prod' 'hidden-title': 'This is visible in the resource name' @@ -295,15 +280,6 @@ module resourceGroup 'br/public:avm/res/resources/resource-group:' = { "value": "avm-resources.resourcegroups-rrgwaf-rg" }, // Non-required parameters - "location": { - "value": "" - }, - "lock": { - "value": { - "kind": "CanNotDelete", - "name": "myCustomLockName" - } - }, "tags": { "value": { "Environment": "Non-Prod", @@ -328,11 +304,6 @@ using 'br/public:avm/res/resources/resource-group:' // Required parameters param name = 'avm-resources.resourcegroups-rrgwaf-rg' // Non-required parameters -param location = '' -param lock = { - kind: 'CanNotDelete' - name: 'myCustomLockName' -} param tags = { Environment: 'Non-Prod' 'hidden-title': 'This is visible in the resource name' @@ -532,6 +503,14 @@ Tags of the storage account resource. | `name` | string | The name of the resource group. | | `resourceId` | string | The resource ID of the resource group. | +## Cross-referenced modules + +This section gives you an overview of all local-referenced module files (i.e., other modules that are referenced in this module) and all remote-referenced files (i.e., Bicep modules that are referenced from a Bicep Registry or Template Specs). + +| Reference | Type | +| :-- | :-- | +| `br/public:avm/utl/types/avm-common-types:0.4.1` | Remote reference | + ## Data Collection The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the [repository](https://aka.ms/avm/telemetry). There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at . You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices. diff --git a/avm/res/resources/resource-group/main.bicep b/avm/res/resources/resource-group/main.bicep index b173bd9d03..f504d0cff4 100644 --- a/avm/res/resources/resource-group/main.bicep +++ b/avm/res/resources/resource-group/main.bicep @@ -10,11 +10,13 @@ param name string @description('Optional. Location of the Resource Group. It uses the deployment\'s location when not provided.') param location string = deployment().location +import { lockType } from 'br/public:avm/utl/types/avm-common-types:0.4.1' @description('Optional. The lock settings of the service.') -param lock lockType +param lock lockType? +import { roleAssignmentType } from 'br/public:avm/utl/types/avm-common-types:0.4.1' @description('Optional. Array of role assignments to create.') -param roleAssignments roleAssignmentType +param roleAssignments roleAssignmentType[]? @description('Optional. Tags of the storage account resource.') param tags object? @@ -75,41 +77,3 @@ output resourceId string = resourceGroup.id @description('The location the resource was deployed into.') output location string = resourceGroup.location - -// =============== // -// Definitions // -// =============== // - -type lockType = { - @description('Optional. Specify the name of lock.') - name: string? - - @description('Optional. Specify the type of lock.') - kind: ('CanNotDelete' | 'ReadOnly' | 'None')? -}? - -type roleAssignmentType = { - @description('Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated.') - name: string? - - @description('Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'.') - roleDefinitionIdOrName: string - - @description('Required. The principal ID of the principal (user/group/identity) to assign the role to.') - principalId: string - - @description('Optional. The principal type of the assigned principal ID.') - principalType: ('ServicePrincipal' | 'Group' | 'User' | 'ForeignGroup' | 'Device')? - - @description('Optional. The description of the role assignment.') - description: string? - - @description('Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase "foo_storage_container".') - condition: string? - - @description('Optional. Version of the condition.') - conditionVersion: '2.0'? - - @description('Optional. The Resource Id of the delegated managed identity resource.') - delegatedManagedIdentityResourceId: string? -}[]? diff --git a/avm/res/resources/resource-group/main.json b/avm/res/resources/resource-group/main.json index 3e371b3059..cfdc690cfa 100644 --- a/avm/res/resources/resource-group/main.json +++ b/avm/res/resources/resource-group/main.json @@ -5,8 +5,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.29.47.4906", - "templateHash": "12280129054844550830" + "version": "0.32.4.45862", + "templateHash": "15310777892883158544" }, "name": "Resource Groups", "description": "This module deploys a Resource Group.", @@ -36,80 +36,87 @@ } } }, - "nullable": true + "metadata": { + "description": "An AVM-aligned type for a lock.", + "__bicep_imported_from!": { + "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.4.1" + } + } }, "roleAssignmentType": { - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { - "type": "string", - "nullable": true, - "metadata": { - "description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated." - } - }, - "roleDefinitionIdOrName": { - "type": "string", - "metadata": { - "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'." - } - }, - "principalId": { - "type": "string", - "metadata": { - "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to." - } - }, - "principalType": { - "type": "string", - "allowedValues": [ - "Device", - "ForeignGroup", - "Group", - "ServicePrincipal", - "User" - ], - "nullable": true, - "metadata": { - "description": "Optional. The principal type of the assigned principal ID." - } - }, - "description": { - "type": "string", - "nullable": true, - "metadata": { - "description": "Optional. The description of the role assignment." - } - }, - "condition": { - "type": "string", - "nullable": true, - "metadata": { - "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"." - } - }, - "conditionVersion": { - "type": "string", - "allowedValues": [ - "2.0" - ], - "nullable": true, - "metadata": { - "description": "Optional. Version of the condition." - } - }, - "delegatedManagedIdentityResourceId": { - "type": "string", - "nullable": true, - "metadata": { - "description": "Optional. The Resource Id of the delegated managed identity resource." - } + "type": "object", + "properties": { + "name": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated." + } + }, + "roleDefinitionIdOrName": { + "type": "string", + "metadata": { + "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'." + } + }, + "principalId": { + "type": "string", + "metadata": { + "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to." + } + }, + "principalType": { + "type": "string", + "allowedValues": [ + "Device", + "ForeignGroup", + "Group", + "ServicePrincipal", + "User" + ], + "nullable": true, + "metadata": { + "description": "Optional. The principal type of the assigned principal ID." + } + }, + "description": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The description of the role assignment." + } + }, + "condition": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"." + } + }, + "conditionVersion": { + "type": "string", + "allowedValues": [ + "2.0" + ], + "nullable": true, + "metadata": { + "description": "Optional. Version of the condition." + } + }, + "delegatedManagedIdentityResourceId": { + "type": "string", + "nullable": true, + "metadata": { + "description": "Optional. The Resource Id of the delegated managed identity resource." } } }, - "nullable": true + "metadata": { + "description": "An AVM-aligned type for a role assignment.", + "__bicep_imported_from!": { + "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.4.1" + } + } } }, "parameters": { @@ -128,12 +135,17 @@ }, "lock": { "$ref": "#/definitions/lockType", + "nullable": true, "metadata": { "description": "Optional. The lock settings of the service." } }, "roleAssignments": { - "$ref": "#/definitions/roleAssignmentType", + "type": "array", + "items": { + "$ref": "#/definitions/roleAssignmentType" + }, + "nullable": true, "metadata": { "description": "Optional. Array of role assignments to create." } @@ -209,8 +221,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.29.47.4906", - "templateHash": "16740360506283584978" + "version": "0.32.4.45862", + "templateHash": "1203907446887412297" } }, "definitions": { @@ -295,8 +307,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.29.47.4906", - "templateHash": "10992477577200576081" + "version": "0.32.4.45862", + "templateHash": "6029968255804453751" } }, "definitions": { diff --git a/avm/res/resources/resource-group/tests/e2e/defaults/main.test.bicep b/avm/res/resources/resource-group/tests/e2e/defaults/main.test.bicep index 265479917f..6aa3ede533 100644 --- a/avm/res/resources/resource-group/tests/e2e/defaults/main.test.bicep +++ b/avm/res/resources/resource-group/tests/e2e/defaults/main.test.bicep @@ -26,7 +26,6 @@ module testDeployment '../../../main.bicep' = [ name: '${uniqueString(deployment().name, resourceLocation)}-test-${serviceShort}-${iteration}' params: { name: 'avm-${namePrefix}-resources.resourcegroups-${serviceShort}-rg' - location: resourceLocation } } ] diff --git a/avm/res/resources/resource-group/tests/e2e/waf-aligned/main.test.bicep b/avm/res/resources/resource-group/tests/e2e/waf-aligned/main.test.bicep index d0bdb8a832..e5a1f58f74 100644 --- a/avm/res/resources/resource-group/tests/e2e/waf-aligned/main.test.bicep +++ b/avm/res/resources/resource-group/tests/e2e/waf-aligned/main.test.bicep @@ -23,12 +23,7 @@ param namePrefix string = '#_namePrefix_#' module testDeployment '../../../main.bicep' = { name: '${uniqueString(deployment().name, resourceLocation)}-test-${serviceShort}' params: { - location: resourceLocation name: 'avm-${namePrefix}-resources.resourcegroups-${serviceShort}-rg' - lock: { - kind: 'CanNotDelete' - name: 'myCustomLockName' - } tags: { 'hidden-title': 'This is visible in the resource name' Environment: 'Non-Prod'