Skip to content

Instantly share code, notes, and snippets.

@GrillPhil
Created July 24, 2023 12:09
Show Gist options
  • Save GrillPhil/e6707be370e3d6c81a0378d47c14a733 to your computer and use it in GitHub Desktop.
Save GrillPhil/e6707be370e3d6c81a0378d47c14a733 to your computer and use it in GitHub Desktop.
param keyVaultName string
param principalId string
param roleId string = '4633458b-17de-408a-b874-0445c86b69e6' // Key Vault Secrets User
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
name: keyVaultName
}
resource keyVaultAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(subscription().subscriptionId, keyVaultName, roleId, principalId)
scope: keyVault
properties: {
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleId)
principalId: principalId
principalType: 'ServicePrincipal'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment