Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report]: Management Group Deployment not working #1342

Closed
AlexanderSehr opened this issue Apr 27, 2022 · 7 comments
Closed

[Bug Report]: Management Group Deployment not working #1342

AlexanderSehr opened this issue Apr 27, 2022 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@AlexanderSehr
Copy link
Contributor

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

@AlexanderSehr AlexanderSehr added the bug Something isn't working label Apr 27, 2022
@MattLeach25
Copy link

Investigated this morning and came to the same conclusion as Alexander. I believe it's an issue with the implicit dependency and the RBAC is trying to deploy before the management group has been created, therefore not being able to find it. If you use a management group that already exists, everything works nicely. Bug raised on the Azure / Bicep Repo - Azure/bicep#6832

@MariusStorhaug
Copy link
Contributor

Is this duplicate of #1320 ?

@eriqua
Copy link
Contributor

eriqua commented Jun 16, 2022

Is this issue on the Bicep team? Should we put it as blocked?
Alternatively, if the issue is on the rbac, should we discuss if removing the rbac property for now to have at least the MG module working?

@MattLeach25
Copy link

Is this issue on the Bicep team? Should we put it as blocked? Alternatively, if the issue is on the rbac, should we discuss if removing the rbac property for now to have at least the MG module working?

Yeah maybe we should comment out the RBAC bit for now until we get a response back from the Bicep team. @MrMCake are you happy with this approach?

@eriqua
Copy link
Contributor

eriqua commented Jul 9, 2022

RBAC has been removed from the module implementation which now deploys fine. I'd suggest to close this bug and open a feature request issue to add the RBAC option back in the module once the Azure/bicep#6832 bug is fixed.

@AlexanderSehr
Copy link
Contributor Author

@eriqua, agreed.

@eriqua
Copy link
Contributor

eriqua commented Jul 18, 2022

The feature request to add RBAC back is already open. Refer to #1543. Closing.

@eriqua eriqua closed this as completed Jul 18, 2022
@eriqua eriqua closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2022
@rahalan rahalan moved this to Closed in Bug board Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Closed
Development

No branches or pull requests

4 participants