-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EES-4765 Add conditional deploy of ACR Pull role assignment
- Loading branch information
Showing
6 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param identityName string | ||
|
||
param deployRoleAssignments bool = true | ||
|
||
resource apiIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = { | ||
name: identityName | ||
location: location | ||
tags: tags | ||
} | ||
|
||
module containerRegistryAccess '../shared/container-registry-access.bicep' = if (deployRoleAssignments) { | ||
name: '${name}-container-registry-access' | ||
params: { | ||
principalId: apiIdentity.properties.principalId | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param identityName string | ||
|
||
param deployRoleAssignments bool = true | ||
|
||
resource webIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = { | ||
name: identityName | ||
location: location | ||
tags: tags | ||
} | ||
|
||
module containerRegistryAccess '../shared/container-registry-access.bicep' = if (deployRoleAssignments) { | ||
name: '${name}-container-registry-access' | ||
params: { | ||
principalId: webIdentity.properties.principalId | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
metadata description = 'Assigns ACR Pull role to access an Azure Container Registry.' | ||
|
||
param principalId string | ||
|
||
var acrPullRole = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d') | ||
|
||
// This requires Microsoft.Authorization/roleAssignments/write permission, | ||
// such as being an Owner, User Access Administrator, or RBAC Administrator at the scope the role is being assigned. | ||
resource acrPullRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
scope: resourceGroup() // Scope is specified as the resource group level but this could be changed to be a specific ACR resource | ||
name: guid(resourceGroup().id, principalId, acrPullRole) | ||
properties: { | ||
roleDefinitionId: acrPullRole | ||
principalType: 'ServicePrincipal' | ||
principalId: principalId | ||
} | ||
} |