Azure / Azure/bicep

Look up existing resources by properties other than name

Open
#4,917 26 comments 3 reactions 0 assignees View on GitHub
enhancement Needs: Upvote
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.**
If one attempts to deploy a role assignment that already exists, the deployment will fail instead of gracefully acknowledging that the resource already exists and skipping it. If there were an "exists" method as covered in [this issue](https://github.com/Azure/bicep/issues/4023), I would still have a hard time applying it to role assignments.

A role assignment has the following properties:
- RoleAssignmentId
- Scope
- DisplayName
- SignInName
- RoleDefinitionName
- RoleDefinitionId
- ObjectId
- ObjectType
- CanDelegate
- Description
- ConditionVersion
- Condition

Unfortunately, none of those are the `name` property that must be used to describe an existing resource in Bicep.

**Describe the solution you'd like**
I'd like to have some way to describe such an assignment nonetheless using any of the other properties, as in the following:

```
resource assignment 'Microsoft.Authorization/roleAssignments@' existing = {
DisplayName: 'MyName'
RoleDefinitionName: 'MyRoleName'
}
```

Of course, this is no use until there is an `exists` method available, but following that, it would be an ideal to have it on the roadmap afterwards.

Contributor guide

Open the contributing guide

Research direction

Start with the linked issue 4023 and the role-assignment properties listed here; investigate how existing-resource declarations currently require a name and how an exists method would interact with property-based lookup. Done means a defined and implemented way to identify existing role assignments by a non-name property, with its behavior documented and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.