Automatic naming for role assignments
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Is your feature request related to a problem? Please describe.**
Role assignment naming is hard to get right in ARM. I think the best way of doing it is using the `guid` function to hash **all** the parameters of the role assignment. This way templates remain fully idempotent, and avoid "role assignment exists" errors.
**Describe the solution you'd like**
```bicep
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = {
name: auto
properties: {
roleDefinitionId: roleDefinitionId
principalId: principalId
principalType: 'ServicePrincipal'
}
}
```
`name` would be equal to `guid(scope, roleDefinitionId, principalId, principalType)` (or perhaps generalized as, `guid(scope, prop1, prop2, ...)`. This also forces `principalId` (and other parameters) to be statically-known - which is great since using dynamic values makes the name non-idempotent.
Note this can also be used for Cosmos's `Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments` (and possibly others).
Contributor guide
Research direction
No files, tests, or entry points are identified. Start by tracing how Bicep validates and lowers resource names, especially for role assignments; compare the proposed auto name with ARM idempotency and the Cosmos SQL role-assignment case. Done means the supported syntax and scope are decided and deterministic naming is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100