Skip to content

Commit

Permalink
do not deploy check prescription status udpate if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-nhs committed Jul 3, 2024
1 parent 21915ab commit 8fd99cf
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/run_release_code_and_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ jobs:
TRUSTSTORE_FILE: ${{ inputs.TRUSTSTORE_FILE }}
VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }}
DYNAMODB_AUTOSCALE: ${{ inputs.DYNAMODB_AUTOSCALE }}
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: ${{ inputs.DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE }}
run: ./release_code.sh

- name: Deploy PSU API
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ sam-deploy-package: guard-artifact_bucket guard-artifact_bucket_prefix guard-sta
CommitId=$$COMMIT_ID \
LogLevel=$$LOG_LEVEL \
LogRetentionInDays=$$LOG_RETENTION_DAYS \
Env=$$TARGET_ENVIRONMENT
Env=$$TARGET_ENVIRONMENT \
DeployCheckPrescriptionStatusUpdate=$$DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE

compile-node:
npx tsc --build tsconfig.build.json
Expand Down
19 changes: 17 additions & 2 deletions SAMtemplates/apis/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ Parameters:
EnableSplunk:
Type: String

DeployCheckPrescriptionStatusUpdate:
Type: String

Conditions:
ShouldUseMutualTLS: !Equals
- true
- !Ref EnableMutualTLS
ShouldDeployCheckPrescriptionStatusUpdate: !Equals
- true
- !Ref DeployCheckPrescriptionStatusUpdate

Resources:
GenerateCertificate:
Expand Down Expand Up @@ -462,13 +468,15 @@ Resources:
Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${CapabilityStatementFunctionArn}/invocations

CheckPrescriptionStatusUpdatesResource:
Condition: ShouldDeployCheckPrescriptionStatusUpdate
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref RestApiGateway
ParentId: !GetAtt RestApiGateway.RootResourceId
PathPart: checkprescriptionstatusupdates

CheckPrescriptionStatusUpdatesMethod:
Condition: ShouldDeployCheckPrescriptionStatusUpdate
Type: AWS::ApiGateway::Method
Properties:
RestApiId: !Ref RestApiGateway
Expand All @@ -493,7 +501,10 @@ Resources:
- StatusLambdaMethod
- CapabilityStatementMethod
- Format1UpdatePrescriptionStatusMethod
- CheckPrescriptionStatusUpdatesMethod
- !If
- ShouldDeployCheckPrescriptionStatusUpdate
- CheckPrescriptionStatusUpdatesMethod
- !Ref AWS::NoValue
# see note above if you add something in here when you add a new endpoint
Properties:
RestApiId: !Ref RestApiGateway
Expand Down Expand Up @@ -527,7 +538,11 @@ Resources:
- Fn::ImportValue: !Sub ${StackName}:functions:${StatusFunctionName}:ExecuteLambdaPolicyArn
- Fn::ImportValue: !Sub ${StackName}:functions:${CapabilityStatementFunctionName}:ExecuteLambdaPolicyArn
- Fn::ImportValue: !Sub ${StackName}:state-machines:${Format1UpdatePrescriptionsStatusStateMachineName}:ExecuteStateMachinePolicy
- Fn::ImportValue: !Sub ${StackName}:functions:${CheckPrescriptionStatusUpdatesFunctionName}:ExecuteLambdaPolicyArn
- !If
- ShouldDeployCheckPrescriptionStatusUpdate
- Fn::ImportValue: !Sub ${StackName}:functions:${CheckPrescriptionStatusUpdatesFunctionName}:ExecuteLambdaPolicyArn
- !Ref AWS::NoValue

ApiName: !Sub ${StackName}-apigw
LogRetentionInDays: !Ref LogRetentionInDays
EnableSplunk: !Ref EnableSplunk
20 changes: 18 additions & 2 deletions SAMtemplates/functions/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Parameters:
CommitId:
Type: String

DeployCheckPrescriptionStatusUpdate:
Type: String

Conditions:
ShouldDeployCheckPrescriptionStatusUpdate: !Equals
- true
- !Ref DeployCheckPrescriptionStatusUpdate

Resources:
UpdatePrescriptionStatus:
Type: AWS::Serverless::Function
Expand Down Expand Up @@ -230,6 +238,7 @@ Resources:
SplunkDeliveryStreamArn: !ImportValue lambda-resources:SplunkDeliveryStream

CheckPrescriptionStatusUpdates:
Condition: ShouldDeployCheckPrescriptionStatusUpdate
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${StackName}-CheckPrescriptionStatusUpdates
Expand All @@ -251,6 +260,7 @@ Resources:
- checkPrescriptionStatusUpdates/src/checkPrescriptionStatusUpdates.ts

CheckPrescriptionStatusUpdatesResources:
Condition: ShouldDeployCheckPrescriptionStatusUpdate
Type: AWS::Serverless::Application
Properties:
Location: lambda_resources.yaml
Expand Down Expand Up @@ -315,8 +325,14 @@ Outputs:

CheckPrescriptionStatusUpdatesFunctionName:
Description: The function name of the CheckPrescriptionStatusUpdates lambda
Value: !Ref CheckPrescriptionStatusUpdates
Value: !If
- ShouldDeployCheckPrescriptionStatusUpdate
- !Ref CheckPrescriptionStatusUpdates
- !Ref AWS::NoValue

CheckPrescriptionStatusUpdatesFunctionArn:
Description: The function ARN of the CheckPrescriptionStatusUpdates lambda
Value: !GetAtt CheckPrescriptionStatusUpdates.Arn
Value: !If
- ShouldDeployCheckPrescriptionStatusUpdate
- !GetAtt CheckPrescriptionStatusUpdates.Arn
- !Ref AWS::NoValue
5 changes: 5 additions & 0 deletions SAMtemplates/main_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Parameters:
Type: String
Default: "xxx"

DeployCheckPrescriptionStatusUpdate:
Type: String

Resources:
Tables:
Type: AWS::Serverless::Application
Expand Down Expand Up @@ -97,6 +100,7 @@ Resources:
CheckPrescriptionStatusUpdatesFunctionArn: !GetAtt Functions.Outputs.CheckPrescriptionStatusUpdatesFunctionArn
LogRetentionInDays: !Ref LogRetentionInDays
EnableSplunk: !Ref EnableSplunk
DeployCheckPrescriptionStatusUpdate: !Ref DeployCheckPrescriptionStatusUpdate

Functions:
Type: AWS::Serverless::Application
Expand All @@ -110,6 +114,7 @@ Resources:
EnableSplunk: !Ref EnableSplunk
VersionNumber: !Ref VersionNumber
CommitId: !Ref CommitId
DeployCheckPrescriptionStatusUpdate: !Ref DeployCheckPrescriptionStatusUpdate

StateMachines:
Type: AWS::Serverless::Application
Expand Down

0 comments on commit 8fd99cf

Please sign in to comment.