RBAC - Modification / Removal in BICEP #4432
-
Hi , I am working RBAC assignment in bicep and got stuck in an issue , requesting your help on the same please.
As you know RBAC is an operational governance stuff so there will be RBAC assignment and removal very often in an environment . I am trying to do the same using bicep and one of the principle which I have taken while developing it was to make it more simple. Since my thought process was to make it simple and very scalable approach , I thought to orchestrate it using below logic.
But I got stuck with a modification update issue and would like to know how this can be resolved. Scenario : let say in the first deployment pass , I have assigned below security groups starting with mg1 and mg2 to a role and in the second deployment cycle , I have removed mg2 and replaced with a security group called mg3. Once the deployment is completed we can see that all three security groups are assigned with this role but what I need is only mg1 and mg3 should be assigned with the role when the second deployment completes. Current problem is only with RBAC assignment and removal as it is not doing the modifications as it is needed. What I am trying to achieve is to keep the rbac assignment as mentioned in the environment file and if we take above scenario as example again , the role should only be associated with mg1 and mg2 as I stated. As like RBAC assignment ,can I do the RBAC removal as well using another resource block please. The reason I have used a for loop for RBAC assignment is that to make the RBAC assignment and removal simple. let say if we need to do give access to new security group to existing role , just add it in the environment file then do the deployment and no need to do any code level change. Please let me know how I can solve this . thank you . First Pass Inputs
Second Pass Inputs AccessGrantedADObjectIds: [ ---- Code --------- main.bicep
azure-rbac-roles-mg1-01.bicep
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
I wonder if the new Deployment Stacks will be able to target MGs, Subs & RGs since that is where some of the lifecycle capabilities are going to come from. Will have to keep an eye on this and ask some further questions once the private preview is in play (possibly next month?!). Did you get the sign up link for Deployment Stacks? it was available on the past community call. Sorry no better answer that I can think of at this moment. ARM does not have a remove/cleanup capability at the moment, so you would need to script it out. FYI below (however not applicable here) It's difficult to recommend 'Complete' deployment Modes to most customers, since it can be destructive. It also only works on Resource Group Deployments (as far as I know). i.e. not subscription or MG Scopes. Although it seems like it would be a good fit for MG deployments for your scenario if it was enabled/possible. If you haven't tried Complete Mode (on RG's), please be careful when testing this out. I put some comments on the thread below with some samples. Anything not defined in your current template/deployment will be removed. Please don't delete anything you want to keep, please test in a dev/sandbox resource group. Samples here: #1418 |
Beta Was this translation helpful? Give feedback.
-
Can you clarify a bit more about the scenario of needing to add a role assignment, then quickly remove it? Is this specific to assigning blueprints? Once we have stacks, in two separate deployments of a stack you could do this: Stack at Time 0:
Updated stack at Time 1:
That will remove the role assignment since it is no longer in the bicep/template code. That's more of a scenario of needing the role assignment at one point, but then deciding it's not needed later, so you update the definition of the goal state. What's a bit more unusual about this scenario is that you know at the beginning you won't need the role assignment eventually. cc @bmoore-msft / @apclouds |
Beta Was this translation helpful? Give feedback.
Can you clarify a bit more about the scenario of needing to add a role assignment, then quickly remove it? Is this specific to assigning blueprints?
Once we have stacks, in two separate deployments of a stack you could do this:
Stack at Time 0:
Updated stack at Time 1:
That will remove the role assignment since it is no longer in the bicep/template code.
That's more of a scenario of needing the role assignment at one point, but then deciding it's not needed later, so you update the definition of the goal state. What's a bit more unusual about this scenario is that you know at the beginning you won't need the role assignment eventually.
cc @bmoore-msft …