Skip to content

Commit 8d7b46e

Browse files
committed
ops: pass lambda exec role to reg tests
1 parent e948d31 commit 8d7b46e

9 files changed

Lines changed: 52 additions & 1 deletion

File tree

.github/scripts/release_code.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ sam deploy \
7575
NotifyAPIBaseURLValue="$NOTIFY_API_BASE_URL" \
7676
RequireApplicationName="$REQUIRE_APPLICATION_NAME" \
7777
EnableBackup="$ENABLE_BACKUP" \
78+
PsuExecuteLambdaRoleArn="${PSU_EXECUTE_LAMBDA_ROLE_ARN:-none}" \
7879
TestPresciptionsParamValue1="$TEST_PRESCRIPTIONS_1" \
7980
TestPresciptionsParamValue2="$TEST_PRESCRIPTIONS_2" \
8081
TestPresciptionsParamValue3="$TEST_PRESCRIPTIONS_3" \

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,5 @@ jobs:
196196
secrets:
197197
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
198198
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
199+
DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE }}
199200
PROXYGEN_ROLE: ${{ secrets.PROXYGEN_PTL_ROLE }}

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ jobs:
128128
FORWARD_CSOC_LOGS: false
129129
secrets:
130130
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
131+
DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE }}
131132
PROXYGEN_ROLE: ${{ secrets.PROXYGEN_PTL_ROLE }}
132133
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
133134
release_sandbox_code:

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ jobs:
271271
FORWARD_CSOC_LOGS: false
272272
secrets:
273273
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }}
274+
DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE }}
274275
PROXYGEN_ROLE: ${{ secrets.PROXYGEN_PTL_ROLE }}
275276
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
276277

.github/workflows/run_regression_tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
VERSION_NUMBER:
1010
required: true
1111
type: string
12+
PSU_EXECUTE_LAMBDA_ROLE_ARN:
13+
required: false
14+
type: string
15+
default: ""
1216
REGRESSION_TESTS_PEM:
1317
type: string
1418
pinned_image:
@@ -57,6 +61,7 @@ jobs:
5761
TARGET_ENVIRONMENT: ${{ inputs.ENVIRONMENT }}
5862
VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }}
5963
GITHUB-TOKEN: ${{ steps.generate-token.outputs.token }}
64+
PSU_EXECUTE_LAMBDA_ROLE_ARN: ${{ inputs.PSU_EXECUTE_LAMBDA_ROLE_ARN }}
6065
run: |
6166
if [[ "$TARGET_ENVIRONMENT" != "prod" && "$TARGET_ENVIRONMENT" != "ref" ]]; then
6267
# this should be the tag of the tests you want to run
@@ -76,5 +81,6 @@ jobs:
7681
--is_called_from_github=true \
7782
--product=PSU \
7883
--regression_test_repo_tag "${REGRESSION_TEST_REPO_TAG}" \
79-
--regression_test_workflow_tag "${REGRESSION_TEST_WORKFLOW_TAG}"
84+
--regression_test_workflow_tag "${REGRESSION_TEST_WORKFLOW_TAG}" \
85+
--psu_execute_lambda_role_arn "${PSU_EXECUTE_LAMBDA_ROLE_ARN}"
8086
fi

.github/workflows/run_release_code_and_api.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ on:
121121
pinned_image:
122122
required: true
123123
type: string
124+
PSU_EXECUTE_LAMBDA_ROLE_ARN:
125+
required: false
126+
type: string
127+
default: ""
124128
secrets:
125129
CLOUD_FORMATION_DEPLOY_ROLE:
126130
required: true
@@ -241,6 +245,7 @@ jobs:
241245
TEST_PRESCRIPTIONS_3: ${{ inputs.TEST_PRESCRIPTIONS_3 || 'noval' }}
242246
TEST_PRESCRIPTIONS_4: ${{ inputs.TEST_PRESCRIPTIONS_4 || 'noval' }}
243247
FORWARD_CSOC_LOGS: ${{ inputs.FORWARD_CSOC_LOGS }}
248+
PSU_EXECUTE_LAMBDA_ROLE_ARN: ${{ inputs.PSU_EXECUTE_LAMBDA_ROLE_ARN }}
244249
run: ./release_code.sh
245250

246251
- name: get mtls secrets
@@ -340,6 +345,7 @@ jobs:
340345
with:
341346
ENVIRONMENT: ${{ inputs.APIGEE_ENVIRONMENT }}
342347
VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }}
348+
PSU_EXECUTE_LAMBDA_ROLE_ARN: ${{ inputs.PSU_EXECUTE_LAMBDA_ROLE_ARN }}
343349
pinned_image: "${{ inputs.pinned_image }}"
344350
secrets:
345351
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ sam-sync: guard-AWS_DEFAULT_PROFILE guard-stack_name compile
5353
NotifyAPIBaseURLValue=$${NOTIFY_API_BASE_URL:-https://int.api.service.nhs.uk} \
5454
EnableNotificationsInternal=$${ENABLE_NOTIFICATIONS_INTERNAL:-true} \
5555
EnableNotificationsExternal=$${ENABLE_NOTIFICATIONS_EXTERNAL:-false} \
56+
PsuExecuteLambdaRoleArn=$${PSU_EXECUTE_LAMBDA_ROLE_ARN:-none} \
5657
EnableBackup=$${ENABLE_BACKUP:-False}
5758

5859
sam-deploy: guard-AWS_DEFAULT_PROFILE guard-stack_name
@@ -86,6 +87,7 @@ sam-deploy: guard-AWS_DEFAULT_PROFILE guard-stack_name
8687
NotifyAPIBaseURLValue=$${NOTIFY_API_BASE_URL:-https://int.api.service.nhs.uk} \
8788
EnableNotificationsInternal=$${ENABLE_NOTIFICATIONS_INTERNAL:-true} \
8889
EnableNotificationsExternal=$${ENABLE_NOTIFICATIONS_EXTERNAL:-false} \
90+
PsuExecuteLambdaRoleArn=$${PSU_EXECUTE_LAMBDA_ROLE_ARN:-none} \
8991
EnableBackup=$${ENABLE_BACKUP:-False}
9092

9193
sam-delete: guard-AWS_DEFAULT_PROFILE guard-stack_name

SAMtemplates/functions/main.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ Parameters:
9999
EnableBackup:
100100
Type: String
101101

102+
PsuExecuteLambdaRoleArn:
103+
Type: String
104+
Default: none
105+
102106
TestPrescriptionsParamName1:
103107
Type: String
104108

@@ -120,6 +124,11 @@ Conditions:
120124
- "True"
121125
- !Ref EnableBackup
122126

127+
ShouldGrantPsuExecuteLambdaInvoke: !Not
128+
- !Equals
129+
- !Ref PsuExecuteLambdaRoleArn
130+
- none
131+
123132
Resources:
124133
UpdatePrescriptionStatus:
125134
Type: AWS::Serverless::Function
@@ -279,6 +288,25 @@ Resources:
279288
SplunkSubscriptionFilterRole: !ImportValue lambda-resources:SplunkSubscriptionFilterRole
280289
SplunkDeliveryStreamArn: !ImportValue lambda-resources:SplunkDeliveryStream
281290

291+
GetStatusUpdatesInvokePolicyForRegressionRole:
292+
Condition: ShouldGrantPsuExecuteLambdaInvoke
293+
Type: AWS::IAM::ManagedPolicy
294+
Properties:
295+
Roles:
296+
- !Select
297+
- 1
298+
- !Split
299+
- "role/"
300+
- !Ref PsuExecuteLambdaRoleArn
301+
PolicyDocument:
302+
Version: 2012-10-17
303+
Statement:
304+
- Effect: Allow
305+
Action:
306+
- lambda:InvokeFunction
307+
Resource:
308+
- !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackName}-GetStatusUpdates*
309+
282310
Status:
283311
Type: AWS::Serverless::Function
284312
Properties:

SAMtemplates/main_template.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ Parameters:
174174
AllowedValues:
175175
- true
176176
- false
177+
178+
PsuExecuteLambdaRoleArn:
179+
Type: String
180+
Default: none
177181
Resources:
178182
Secrets:
179183
Type: AWS::Serverless::Application
@@ -273,6 +277,7 @@ Resources:
273277
DeployCheckPrescriptionStatusUpdate: !Ref DeployCheckPrescriptionStatusUpdate
274278
Environment: !Ref Environment
275279
EnableBackup: !Ref EnableBackup
280+
PsuExecuteLambdaRoleArn: !Ref PsuExecuteLambdaRoleArn
276281
RequireApplicationName: !Ref RequireApplicationName
277282
TestPrescriptionsParamName1: !GetAtt Parameters.Outputs.TestPrescriptionsParameterName1
278283
TestPrescriptionsParamName2: !GetAtt Parameters.Outputs.TestPrescriptionsParameterName2

0 commit comments

Comments
 (0)