-
Notifications
You must be signed in to change notification settings - Fork 439
Description
Describe the bug
The current module implementation does not work as the RBAC deployment assumes that the (to be created) management group already exists when you start the deployment. This already happens with the Test-AzManagementGroupDeployment command.
The error is: ManagementGroupNotFound - The management group 'testMG' cannot be found.
The testMG is the one that is to be deployed as per the parameter file.
The code snipped that produces the error:
module managementGroup_rbac '.bicep/nested_rbac.bicep' = [for (roleAssignment, index) in roleAssignments: {
name: '${uniqueString(deployment().name)}-ManagementGroup-Rbac-${index}'
params: {
description: contains(roleAssignment, 'description') ? roleAssignment.description : ''
principalIds: roleAssignment.principalIds
principalType: contains(roleAssignment, 'principalType') ? roleAssignment.principalType : ''
roleDefinitionIdOrName: roleAssignment.roleDefinitionIdOrName
resourceId: managementGroup.id
}
scope: managementGroup
}]The nested_rbac.bicep implementation seems fine and matches 1:1 the Microsoft.Authorization/roleAssignments/managementGroup (working) example.
Note: It seems that there might be a Bicep bug in that the language does not understand how to deal with a management group if you set it as the scope. I already tried different solutions like changing the scopes inside & outside the bicep template, using an extra level of nesting to do the same - all to not avail.
To reproduce
Run a Test-AzManagementGroupDeployment
Code snippet
Execute
> Test-AzManagementGroupDeployment -TemplateParameterFile .\Microsoft.Management\managementGroups\.parameters\parameters.json' -TemplateFile '.\Microsoft.Management\managementGroups\deploy.bicep' -Verbose -ManagementGroupId '<<managementGroupId>>' -Location 'WestEurope'
using the standard parameter file.Relevant log output
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status