Azure / Azure/bicep

Support @allowed attribute on custom type array values

Open
#9,395 7 comments 0 reactions 0 assignees View on GitHub
enhancement Needs: Upvote type system
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 2h
Merged PRs (30d)
79

Description

This is another request related to custom types. I suddenly have a new requirement to spin up a Key Vault instance using Access Policies. I'd like to be able to fully define the desired shape of the per-object policy via custom types, but the lack of support for `@allowed` stands in the way of that. What I'd like to do is the following:

```bicep
type accessPolicyPermissions = {
@allowed([
'Get'
'List'
'Updates'
'Create'
'Import'
'Delete'
'Recover'
'Backup'
'Restore'
'GetRotationPolicy'
'SetRotationPolicy'
'Rotate'
])
keys: string[]
@allowed([
'Get'
'List'
'Set'
'Delete'
'Backup'
'Recover'
])
secrets: string[]
@allowed([
'Get'
'List'
'Update'
'Create'
'Import'
'Delete'
'Recover'
'Backup'
'Restore'
'ManageContacts'
'ManageIssuers'
'GetIssuers'
'ListIssuers'
'SetIssuers'
'DeleteIssuers'
])
certificates: string[]
}

type accessPolicy = {
tenantId: string
objectId: string
permissions: accessPolicyPermissions
}

param accessPolicies accessPolicy[] = []
```

But.. because I cannot today use `@allowed`, I have to entirely opt out of custom types for this purpose leaving me with either specifying the individual arrays themselves for each permission type or opting out altogether and just doing:

```bicep
param AccessPolicies array = []
```

This is far from ideal

Thanks for the consideration!

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Use the two Bicep type examples as acceptance criteria, then locate the existing @allowed handling and add coverage for array-valued properties in custom types.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.