How to modularize a scoped role assignment with Bicep? #5805
-
I need to scope a role assignment to a specific resource, but I'd ideally like to build out a generic module that I can use across my deployments for consistency. If I were assigning a role assignment at the subscription level, I could just do the following:
But I'm running into an issue when I add a string parameter called 'scope' intending to pass it into the scope property on the resource. Namely, the Intellisense offered by Bicep indicates this needs to be either a resource or a tenant value and not a string. I'm trying to scope to a resource and not to a tenant, so it seems I need to specify a resource, but the following isn't valid Bicep:
Now, if I want to make this role assignment specific to one resource type, it's easy enough to solve:
But doing this now means that I need to create duplicate Bicep files for each and every type of resource I'm deploying now and in the future and that's not ideal. Anyone have ideas on how to make this roleAssignment module generic to a passed-in resource type, version and name? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Agree this would be ideal. I don't think this is something that will come to be available in the near future.
These are the proposals for work to be done to encapsulate this capability and this is not currently in scope here. Also this PR is in progress.
|
Beta Was this translation helpful? Give feedback.
-
In looking at this more, it would be nice if there was a
|
Beta Was this translation helpful? Give feedback.
-
@WhitWaldo Another suggestion here using a top-level bicep template with Bicep/ARM as child modules: https://github.com/matsest/az-bicep-roleassignment-multi-scope Still a very much workaround solution, and blocked by the same issue listed by @brwilkinson to be Bicep only |
Beta Was this translation helpful? Give feedback.
Agree this would be ideal.
I don't think this is something that will come to be available in the near future.
These are the proposals for work to be done to encapsulate this capability and this is not currently in scope here.
#2246
#2245
Also this PR is in progress.
#4971
I would recommend to jump in and contribute on those issues/threads to ensure to communicate that this capability is in demand and why, since that is the body of work that would enable this capability. Like I say "Generic Resource Types" as par…