File tree Expand file tree Collapse file tree 5 files changed +27
-18
lines changed
cloud-infrastructure/environment Expand file tree Collapse file tree 5 files changed +27
-18
lines changed Original file line number Diff line number Diff line change @@ -114,21 +114,8 @@ jobs:
114114 STAGING_SUBSCRIPTION_ID : ${{ vars.STAGING_SUBSCRIPTION_ID }}
115115
116116 steps :
117- - name : Login to Azure (Staging)
118- uses : azure/login@v2
119- with :
120- client-id : ${{ env.STAGING_SERVICE_PRINCIPAL_ID }}
121- tenant-id : ${{ env.TENANT_ID }}
122- subscription-id : ${{ env.STAGING_SUBSCRIPTION_ID }}
123117
124- - name : Get Access Token for Staging Azure Subscription
125- id : staging_tokens
126- run : |
127- STAGING_TOKEN=$(az account get-access-token --resource https://management.azure.com --query accessToken -o tsv)
128- echo "::add-mask::$STAGING_TOKEN"
129- echo "access_token=$STAGING_TOKEN" >> $GITHUB_OUTPUT
130-
131- - name : Login to Azure (Production)
118+ - name : Login to Azure
132119 uses : azure/login@v2
133120 with :
134121 client-id : ${{ env.SERVICE_PRINCIPAL_ID }}
@@ -144,7 +131,6 @@ jobs:
144131 --name ${{ env.UNIQUE_PREFIX }}${{ env.ENVIRONMENT }} \
145132 --source ${{ env.UNIQUE_PREFIX }}${{ env.STAGING_ENVIRONMENT }}.azurecr.io/${{ inputs.image_name }}:${{ inputs.version }} \
146133 --image ${{ inputs.image_name }}:${{ inputs.version }} \
147- --password ${{ steps.staging_tokens.outputs.access_token }} \
148134 --force
149135
150136 - name : Deploy Container
@@ -170,4 +156,4 @@ jobs:
170156 echo "($i) Waiting for revision to become active. Running state: $RUNNING_STATUS"
171157 done
172158 echo "New revision did not become active in time. Running state: $RUNNING_STATUS"
173- exit 1
159+ exit 1
Original file line number Diff line number Diff line change 4242 deployment_enabled :
4343 required : true
4444 type : string
45+ production_service_principal_object_id :
46+ required : false
47+ type : string
48+ default : " -"
4549
4650jobs :
4751 plan :
6771
6872 - name : Plan Shared Environment Resources
6973 if : ${{ inputs.include_shared_environment_resources == true }}
70- run : bash ./cloud-infrastructure/environment/deploy-environment.sh ${{ inputs.unique_prefix }} ${{ inputs.azure_environment }} ${{ inputs.shared_location }} --plan
74+ run : bash ./cloud-infrastructure/environment/deploy-environment.sh ${{ inputs.unique_prefix }} ${{ inputs.azure_environment }} ${{ inputs.shared_location }} ${{ inputs.production_service_principal_object_id }} --plan
7175
7276 - name : Plan Cluster Resources
7377 id : deploy_cluster
99103
100104 - name : Deploy Shared Environment Resources
101105 if : ${{ inputs.include_shared_environment_resources == true }}
102- run : bash ./cloud-infrastructure/environment/deploy-environment.sh ${{ inputs.unique_prefix }} ${{ inputs.azure_environment }} ${{ inputs.shared_location }} --apply
106+ run : bash ./cloud-infrastructure/environment/deploy-environment.sh ${{ inputs.unique_prefix }} ${{ inputs.azure_environment }} ${{ inputs.shared_location }} ${{ inputs.production_service_principal_object_id }} --apply
103107
104108 - name : Deploy Cluster Resources
105109 id : deploy_cluster
Original file line number Diff line number Diff line change 4141 tenant_id : ${{ vars.TENANT_ID }}
4242 subscription_id : ${{ vars.STAGING_SUBSCRIPTION_ID }}
4343 deployment_enabled : ${{ vars.STAGING_CLUSTER_ENABLED }}
44+ production_service_principal_object_id : ${{ vars.PRODUCTION_SERVICE_PRINCIPAL_OBJECT_ID }}
4445
4546 prod1 :
4647 name : Production
Original file line number Diff line number Diff line change 33UNIQUE_PREFIX=$1
44ENVIRONMENT=$2
55LOCATION_SHARED=$3
6+ PRODUCTION_SERVICE_PRINCIPAL_OBJECT_ID=$4
67
78RESOURCE_GROUP_NAME=$UNIQUE_PREFIX -$ENVIRONMENT
89CONTAINER_REGISTRY_NAME=$UNIQUE_PREFIX$ENVIRONMENT
910CURRENT_DATE=$( date +' %Y-%m-%dT%H-%M' )
1011DEPLOYMENT_COMMAND=" az deployment sub create"
1112DEPLOYMENT_PARAMETERS=" -l $LOCATION_SHARED -n $CURRENT_DATE -$UNIQUE_PREFIX -$ENVIRONMENT --output table -f ./main-environment.bicep -p resourceGroupName=$RESOURCE_GROUP_NAME environment=$ENVIRONMENT containerRegistryName=$CONTAINER_REGISTRY_NAME "
1213
14+ # Add production service principal object ID parameter if provided for ACR Pull role assignment to staging Container Registry
15+ if [[ " $PRODUCTION_SERVICE_PRINCIPAL_OBJECT_ID " != " -" ]]; then
16+ echo " Using production service principal object ID: $PRODUCTION_SERVICE_PRINCIPAL_OBJECT_ID "
17+ DEPLOYMENT_PARAMETERS=" $DEPLOYMENT_PARAMETERS productionServicePrincipalObjectId=$PRODUCTION_SERVICE_PRINCIPAL_OBJECT_ID "
18+ fi
19+
1320cd " $( dirname " ${BASH_SOURCE[0]} " ) "
1421. ../deploy.sh
1522
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ param location string = deployment().location
44param resourceGroupName string
55param environment string
66param containerRegistryName string
7+ param productionServicePrincipalObjectId string = ''
78
89var tags = { environment : environment , 'managed-by' : 'bicep' }
910
@@ -23,6 +24,16 @@ module containerRegistry '../modules/container-registry.bicep' = {
2324 }
2425}
2526
27+ // Grant production service principal ACR Pull access to registry if specified
28+ module productionServicePrincipalAcrPull '../modules/role-assignments-container-registry-acr-pull.bicep' = if (!empty (productionServicePrincipalObjectId )) {
29+ name : '${resourceGroupName }-production-sp-acr-pull'
30+ scope : resourceGroup (environmentResourceGroup .name )
31+ params : {
32+ containerRegistryName : containerRegistryName
33+ principalId : productionServicePrincipalObjectId
34+ }
35+ }
36+
2637module logAnalyticsWorkspace '../modules/log-analytics-workspace.bicep' = {
2738 name : '${resourceGroupName }-log-analytics-workspace'
2839 scope : resourceGroup (environmentResourceGroup .name )
You can’t perform that action at this time.
0 commit comments