@@ -54,6 +54,14 @@ Parameters:
5454 Type : String
5555 Default : none
5656
57+ GetStatusUpdatesFunctionName :
58+ Type : String
59+ Default : none
60+
61+ GetStatusUpdatesFunctionArn :
62+ Type : String
63+ Default : none
64+
5765 NHSNotifyUpdateCallbackFunctionName :
5866 Type : String
5967 Default : none
@@ -71,6 +79,10 @@ Parameters:
7179 DeployCheckPrescriptionStatusUpdate :
7280 Type : String
7381
82+ ExposeGetStatusUpdates :
83+ Type : String
84+ Default : false
85+
7486 ForwardCsocLogs :
7587 Type : String
7688 Default : false
@@ -81,6 +93,9 @@ Conditions:
8193 ShouldDeployCheckPrescriptionStatusUpdate : !Equals
8294 - true
8395 - !Ref DeployCheckPrescriptionStatusUpdate
96+ ShouldExposeGetStatusUpdates : !Equals
97+ - true
98+ - !Ref ExposeGetStatusUpdates
8499
85100Resources :
86101 GenerateCertificate :
@@ -526,6 +541,58 @@ Resources:
526541 IntegrationHttpMethod : POST
527542 Uri : !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${CheckPrescriptionStatusUpdatesFunctionArn}/invocations
528543
544+ GetStatusUpdatesResource :
545+ Condition : ShouldExposeGetStatusUpdates
546+ Type : AWS::ApiGateway::Resource
547+ Properties :
548+ RestApiId : !Ref RestApiGateway
549+ ParentId : !GetAtt RestApiGateway.RootResourceId
550+ PathPart : get-status-updates
551+
552+ GetStatusUpdatesMethod :
553+ Condition : ShouldExposeGetStatusUpdates
554+ Type : AWS::ApiGateway::Method
555+ Properties :
556+ RestApiId : !Ref RestApiGateway
557+ ResourceId : !Ref GetStatusUpdatesResource
558+ HttpMethod : POST
559+ AuthorizationType : NONE
560+ Integration :
561+ Type : AWS
562+ Credentials : !GetAtt RestApiGatewayResources.Outputs.ApiGwRoleArn
563+ IntegrationHttpMethod : POST
564+ Uri : !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetStatusUpdatesFunctionArn}/invocations
565+ RequestTemplates :
566+ application/json : |-
567+ $input.json('$')
568+ IntegrationResponses :
569+ - StatusCode : 200
570+ ResponseTemplates :
571+ application/json : |-
572+ $input.body
573+ MethodResponses :
574+ - StatusCode : " 200"
575+
576+ GetStatusUpdatesHandle :
577+ Condition : ShouldExposeGetStatusUpdates
578+ DependsOn : GetStatusUpdatesMethod
579+ Type : " AWS::CloudFormation::WaitConditionHandle"
580+
581+ GetStatusUpdatesWaitHandle :
582+ Type : " AWS::CloudFormation::WaitConditionHandle"
583+
584+ GetStatusUpdatesWaitCondition :
585+ Type : " AWS::CloudFormation::WaitCondition"
586+ Properties :
587+ Handle :
588+ !If [
589+ ShouldExposeGetStatusUpdates,
590+ !Ref GetStatusUpdatesHandle,
591+ !Ref GetStatusUpdatesWaitHandle,
592+ ]
593+ Timeout : " 1"
594+ Count : 0
595+
529596 # we can not use a conditional in depends on in ApiGateway::Deployment
530597 # so instead we use a wait condition that has the conditional in it and use that as a dependency
531598 # taken from https://garbe.io/blog/2017/07/17/cloudformation-hacks/
@@ -553,7 +620,7 @@ Resources:
553620 # if you add a new endpoint, then change the name of this resource
554621 # also need to change it in RestApiGatewayStage.Properties.DeploymentId
555622 # *********************************************************************
556- RestApiGatewayDeploymentV2f :
623+ RestApiGatewayDeploymentV2h :
557624 Type : AWS::ApiGateway::Deployment
558625 DependsOn :
559626 # see note above if you add something in here when you add a new endpoint
@@ -563,6 +630,7 @@ Resources:
563630 - Format1UpdatePrescriptionStatusMethod
564631 - CheckPrescriptionStatusUpdatesWaitCondition
565632 - NotificationDeliveryStatusCallbackMethod
633+ - GetStatusUpdatesWaitCondition
566634 # see note above if you add something in here when you add a new endpoint
567635 Properties :
568636 RestApiId : !Ref RestApiGateway
@@ -571,7 +639,7 @@ Resources:
571639 Type : AWS::ApiGateway::Stage
572640 Properties :
573641 RestApiId : !Ref RestApiGateway
574- DeploymentId : !Ref RestApiGatewayDeploymentV2f
642+ DeploymentId : !Ref RestApiGatewayDeploymentV2h
575643 StageName : prod
576644 TracingEnabled : true
577645 AccessLogSetting :
@@ -595,6 +663,10 @@ Resources:
595663 - Fn::ImportValue : !Sub ${StackName}:functions:${StatusFunctionName}:ExecuteLambdaPolicyArn
596664 - Fn::ImportValue : !Sub ${StackName}:functions:${CapabilityStatementFunctionName}:ExecuteLambdaPolicyArn
597665 - Fn::ImportValue : !Sub ${StackName}:functions:${NHSNotifyUpdateCallbackFunctionName}:ExecuteLambdaPolicyArn
666+ - !If
667+ - ShouldExposeGetStatusUpdates
668+ - Fn::ImportValue : !Sub ${StackName}:functions:${GetStatusUpdatesFunctionName}:ExecuteLambdaPolicyArn
669+ - !Ref AWS::NoValue
598670 - Fn::ImportValue : !Sub ${StackName}:state-machines:${Format1UpdatePrescriptionsStatusStateMachineName}:ExecuteStateMachinePolicy
599671 - !If
600672 - ShouldDeployCheckPrescriptionStatusUpdate
0 commit comments