@@ -25,6 +25,14 @@ Parameters:
2525 Type : String
2626 Default : none
2727
28+ PrescriptionNotificationStateTableName :
29+ Type : String
30+ Default : none
31+
32+ NHSNotifyPrescriptionsSQSQueueUrl :
33+ Type : String
34+ Default : none
35+
2836 LogLevel :
2937 Type : String
3038
@@ -62,6 +70,7 @@ Resources:
6270 Environment :
6371 Variables :
6472 TABLE_NAME : !Ref PrescriptionStatusUpdatesTableName
73+ NHS_NOTIFY_PRESCRIPTIONS_SQS_QUEUE_URL : !Ref NHSNotifyPrescriptionsSQSQueueUrl
6574 LOG_LEVEL : !Ref LogLevel
6675 ENVIRONMENT : !Ref Environment
6776 TEST_PRESCRIPTIONS_1 : " None"
@@ -96,6 +105,8 @@ Resources:
96105 - - Fn::ImportValue : !Sub ${StackName}:tables:${PrescriptionStatusUpdatesTableName}:TableWritePolicyArn
97106 - Fn::ImportValue : !Sub ${StackName}:tables:${PrescriptionStatusUpdatesTableName}:TableReadPolicyArn
98107 - Fn::ImportValue : !Sub ${StackName}:tables:UsePrescriptionStatusUpdatesKMSKeyPolicyArn
108+ - Fn::ImportValue : !Sub ${StackName}-UseNotificationSQSQueueKMSKeyPolicyArn
109+ - Fn::ImportValue : !Sub ${StackName}-WriteNHSNotifyPrescriptionsSQSQueuePolicyArn
99110 LogRetentionInDays : !Ref LogRetentionInDays
100111 CloudWatchKMSKeyId : !ImportValue account-resources:CloudwatchLogsKmsKeyArn
101112 EnableSplunk : !Ref EnableSplunk
@@ -320,6 +331,91 @@ Resources:
320331 SplunkSubscriptionFilterRole : !ImportValue lambda-resources:SplunkSubscriptionFilterRole
321332 SplunkDeliveryStreamArn : !ImportValue lambda-resources:SplunkDeliveryStream
322333
334+ NHSNotifyLambdaScheduleEventRole :
335+ Type : AWS::IAM::Role
336+ Properties :
337+ AssumeRolePolicyDocument :
338+ Version : 2012-10-17
339+ Statement :
340+ - Effect : Allow
341+ Principal :
342+ Service :
343+ - scheduler.amazonaws.com
344+ Action :
345+ - sts:AssumeRole
346+ ManagedPolicyArns :
347+ - !Ref NHSNotifyLambdaScheduleEventRolePolicy
348+
349+ NHSNotifyLambdaScheduleEventRolePolicy :
350+ Type : AWS::IAM::ManagedPolicy
351+ Properties :
352+ PolicyDocument :
353+ Version : 2012-10-17
354+ Statement :
355+ - Effect : Allow
356+ Action :
357+ - lambda:InvokeFunction
358+ Resource :
359+ - !GetAtt NHSNotifyLambda.Arn
360+
361+ NHSNotifyLambda :
362+ Type : AWS::Serverless::Function
363+ Properties :
364+ FunctionName : !Sub ${StackName}-NHSNotifyLambda
365+ CodeUri : ../../packages/
366+ Handler : nhsNotifyLambda.handler
367+ Role : !GetAtt NHSNotifyLambdaResources.Outputs.LambdaRoleArn
368+ Environment :
369+ Variables :
370+ LOG_LEVEL : !Ref LogLevel
371+ NHS_NOTIFY_PRESCRIPTIONS_SQS_QUEUE_URL : !Ref NHSNotifyPrescriptionsSQSQueueUrl
372+ TABLE_NAME : !Ref PrescriptionNotificationStateTableName
373+ Events :
374+ ScheduleEvent :
375+ Type : ScheduleV2
376+ Properties :
377+ Name : !Sub ${StackName}-NHSNotifySchedule
378+ ScheduleExpression : " rate(1 minute)"
379+ RoleArn : !GetAtt NHSNotifyLambdaScheduleEventRole.Arn
380+ Metadata :
381+ BuildMethod : esbuild
382+ guard :
383+ SuppressedRules :
384+ - LAMBDA_DLQ_CHECK
385+ - LAMBDA_INSIDE_VPC
386+ - LAMBDA_CONCURRENCY_CHECK
387+ BuildProperties :
388+ Minify : true
389+ Target : es2020
390+ Sourcemap : true
391+ tsconfig : nhsNotifyLambda/tsconfig.json
392+ packages : bundle
393+ EntryPoints :
394+ - nhsNotifyLambda/src/nhsNotifyLambda.ts
395+
396+ NHSNotifyLambdaResources :
397+ Type : AWS::Serverless::Application
398+ Properties :
399+ Location : lambda_resources.yaml
400+ Parameters :
401+ StackName : !Ref StackName
402+ LambdaName : !Sub ${StackName}-NHSNotifyLambda
403+ LambdaArn : !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackName}-NHSNotifyLambda
404+ LogRetentionInDays : !Ref LogRetentionInDays
405+ CloudWatchKMSKeyId : !ImportValue account-resources:CloudwatchLogsKmsKeyArn
406+ EnableSplunk : !Ref EnableSplunk
407+ SplunkSubscriptionFilterRole : !ImportValue lambda-resources:SplunkSubscriptionFilterRole
408+ SplunkDeliveryStreamArn : !ImportValue lambda-resources:SplunkDeliveryStream
409+ IncludeAdditionalPolicies : true
410+ AdditionalPolicies : !Join
411+ - " ,"
412+ - - Fn::ImportValue : !Sub ${StackName}-WriteNHSNotifyPrescriptionsSQSQueuePolicyArn
413+ - Fn::ImportValue : !Sub ${StackName}-ReadNHSNotifyPrescriptionsSQSQueuePolicyArn
414+ - Fn::ImportValue : !Sub ${StackName}-UseNotificationSQSQueueKMSKeyPolicyArn
415+ - Fn::ImportValue : !Sub ${StackName}:tables:${PrescriptionNotificationStateTableName}:TableReadPolicyArn
416+ - Fn::ImportValue : !Sub ${StackName}:tables:${PrescriptionNotificationStateTableName}:TableWritePolicyArn
417+ - Fn::ImportValue : !Sub ${StackName}:tables:UsePrescriptionNotificationStateKMSKeyPolicyArn
418+
323419Outputs :
324420 UpdatePrescriptionStatusFunctionName :
325421 Description : The function name of the UpdatePrescriptionStatus lambda
@@ -378,3 +474,11 @@ Outputs:
378474 - ShouldDeployCheckPrescriptionStatusUpdate
379475 - !GetAtt CheckPrescriptionStatusUpdates.Arn
380476 - " "
477+
478+ NHSNotifyLambdaFunctionName :
479+ Description : The function name of the NHS Notify lambda
480+ Value : !Ref NHSNotifyLambda
481+
482+ NHSNotifyLambdaFunctionArn :
483+ Description : The function ARN of the NHS Notify lambda
484+ Value : !GetAtt NHSNotifyLambda.Arn
0 commit comments