Skip to content

Commit e1c6a9a

Browse files
feat(DTOSS-13037): remove pipeline MI as SP owner and document app role assignment process
The pipeline MI was added as owner of the enterprise app SP to enable Terraform app role assignments, but AppRoleAssignment.ReadWrite.All is required in application auth context regardless of ownership. Since assignments are now handled by assign_arc_app_roles.sh (delegated auth), the MI owner entry is no longer needed. Adds inline documentation explaining the constraint and onboarding process.
1 parent 9f4f793 commit e1c6a9a

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

infrastructure/terraform/resource_group_init/enterpriseAppOwner.bicep

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
extension microsoftGraphV1
22

3-
param miPrincipalId string
43
param enterpriseAppClientId string
54
param enterpriseAppName string
65
param groupMemberIds array = []
76

87
resource enterpriseAppSp 'Microsoft.Graph/servicePrincipals@v1.0' = {
98
appId: enterpriseAppClientId
109
owners: {
11-
relationships: concat([miPrincipalId], groupMemberIds)
10+
relationships: groupMemberIds
1211
}
1312
}
1413

infrastructure/terraform/resource_group_init/main.bicep

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ module pipelineMiAppRole 'enterpriseAppOwner.bicep' = {
214214
name: 'pipelineMiAppRoleAssignment'
215215
scope: managedIdentityRG
216216
params: {
217-
miPrincipalId: managedIdentiyADOtoAZ.outputs.miPrincipalID
218217
enterpriseAppClientId: enterpriseAppClientId
219218
enterpriseAppName: enterpriseAppName
220219
groupMemberIds: groupMemberIds

scripts/bash/assign_arc_app_roles.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
#!/usr/bin/env bash
2+
# Assigns the Gateway.Access app role to the managed identity of each Arc-enabled server
3+
# in the environment, allowing the gateway to authenticate against the web API.
4+
#
5+
# This is intentionally a manual script rather than automated via Terraform because the
6+
# pipeline managed identity (mi-manbrs-<env>-adotoaz-uks) lacks the AppRoleAssignment.ReadWrite.All
7+
# Graph application permission required to create app role assignments. In the delegated auth
8+
# context (user running this script), ownership of the service principal is sufficient.
9+
#
10+
# Run this script after onboarding new Arc-enabled servers to assign the Gateway.Access role
11+
# to their managed identities.
12+
#
13+
# Usage: ./scripts/bash/assign_arc_app_roles.sh <env> <subscription>
14+
# Example: ./scripts/bash/assign_arc_app_roles.sh review "Breast Screening - Manage Breast Screening - Dev"
215
set -eu
316

417
ENV_CONFIG="$1"

scripts/terraform/terraform.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ci: # Skip manual approvals when running in CI - make ci <env> <action>
2121
set-azure-account: # Set the Azure account for the environment - make <env> set-azure-account
2222
[ "${SKIP_AZURE_LOGIN}" != "true" ] && az account set -s ${AZURE_SUBSCRIPTION} || true
2323

24-
resource-group-init: set-azure-account get-subscription-ids # Initialise the resources required by terraform - make <env> resource-group-init
24+
resource-group-init: set-azure-account get-subscription-ids # Initialise resources required by terraform and assign Gateway.Access role to Arc machine managed identities - make <env> resource-group-init
2525
$(eval STORAGE_ACCOUNT_NAME=sa${APP_SHORT_NAME}${ENV_CONFIG}tfstate)
2626
scripts/bash/resource_group_init.sh "${REGION}" "${HUB_SUBSCRIPTION_ID}" "${ENABLE_SOFT_DELETE}" "${ENV_CONFIG}" "${STORAGE_ACCOUNT_RG}" "${STORAGE_ACCOUNT_NAME}" "${APP_SHORT_NAME}" "${ARM_SUBSCRIPTION_ID}"
2727
scripts/bash/assign_arc_app_roles.sh "${ENV_CONFIG}" "${ARM_SUBSCRIPTION_ID}"

0 commit comments

Comments
 (0)