Linter Rule to convert resourceId to `existing` syntax
- 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.**
Existing resources are an awesome part of bicep that are easy to look over. Could a linter rule detect hard coded resource ids, and offer to convert them to use the existing syntax?
**Describe the solution you'd like**
Suggest changing the following:
```bicep
var resourceId = '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.Storage/storageAccounts/accountName'
```
to
```bicep
resource resource 'Microsoft.Storage/storageAccounts@2021-04-01' existing = {
name: 'accountName'
scope: resourceGroup('00000000-0000-0000-0000-000000000000', 'rgName')
}
```
and change all other references to `resourceId` to `resource.id`
Contributor guide
Research direction
Start by locating the linter-rule entry point and the handling of hard-coded resource IDs in the Bicep compiler or analyzer. Define how the rule should recognize IDs, infer the existing resource declaration and scope, and update references to resource.id. Done means the example is transformed correctly and equivalent cases are covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100