Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions SAMtemplates/functions/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Resources:
SplunkSubscriptionFilterRole: !ImportValue lambda-resources:SplunkSubscriptionFilterRole
SplunkDeliveryStreamArn: !ImportValue lambda-resources:SplunkDeliveryStream

NHSNotifyLambdaScheduleEventRole:
NotifyProcessorScheduleEventRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Expand All @@ -356,9 +356,9 @@ Resources:
Action:
- sts:AssumeRole
ManagedPolicyArns:
- !Ref NHSNotifyLambdaScheduleEventRolePolicy
- !Ref NotifyProcessorScheduleEventRolePolicy

NHSNotifyLambdaScheduleEventRolePolicy:
NotifyProcessorScheduleEventRolePolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
PolicyDocument:
Expand All @@ -368,15 +368,15 @@ Resources:
Action:
- lambda:InvokeFunction
Resource:
- !GetAtt NHSNotifyLambda.Arn
- !GetAtt NotifyProcessor.Arn

NHSNotifyLambda:
NotifyProcessor:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${StackName}-NHSNotifyLambda
FunctionName: !Sub ${StackName}-NotifyProcessor
CodeUri: ../../packages/
Handler: nhsNotifyLambda.handler
Role: !GetAtt NHSNotifyLambdaResources.Outputs.LambdaRoleArn
Role: !GetAtt NotifyProcessorResources.Outputs.LambdaRoleArn
Environment:
Variables:
LOG_LEVEL: !Ref LogLevel
Expand All @@ -388,7 +388,7 @@ Resources:
Properties:
Name: !Sub ${StackName}-NHSNotifySchedule
ScheduleExpression: "rate(1 minute)"
RoleArn: !GetAtt NHSNotifyLambdaScheduleEventRole.Arn
RoleArn: !GetAtt NotifyProcessorScheduleEventRole.Arn
Metadata:
BuildMethod: esbuild
guard:
Expand All @@ -405,14 +405,14 @@ Resources:
EntryPoints:
- nhsNotifyLambda/src/nhsNotifyLambda.ts

NHSNotifyLambdaResources:
NotifyProcessorResources:
Type: AWS::Serverless::Application
Properties:
Location: lambda_resources.yaml
Parameters:
StackName: !Ref StackName
LambdaName: !Sub ${StackName}-NHSNotifyLambda
LambdaArn: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackName}-NHSNotifyLambda
LambdaName: !Sub ${StackName}-NotifyProcessor
LambdaArn: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackName}-NotifyProcessor
LogRetentionInDays: !Ref LogRetentionInDays
CloudWatchKMSKeyId: !ImportValue account-resources:CloudwatchLogsKmsKeyArn
EnableSplunk: !Ref EnableSplunk
Expand Down Expand Up @@ -487,10 +487,10 @@ Outputs:
- !GetAtt CheckPrescriptionStatusUpdates.Arn
- ""

NHSNotifyLambdaFunctionName:
NotifyProcessorFunctionName:
Description: The function name of the NHS Notify lambda
Value: !Ref NHSNotifyLambda
Value: !Ref NotifyProcessor

NHSNotifyLambdaFunctionArn:
NotifyProcessorFunctionArn:
Description: The function ARN of the NHS Notify lambda
Value: !GetAtt NHSNotifyLambda.Arn
Value: !GetAtt NotifyProcessor.Arn
6 changes: 3 additions & 3 deletions packages/updatePrescriptionStatus/src/utils/sqsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function pushPrescriptionToNotificationSQS(
data: Array<DataItem>,
logger: Logger
) {
logger.info("Pushing data items up to the notifications SQS", {count: data.length, sqsUrl})
logger.info("Checking if any items require notifications", {numItemsToBeChecked: data.length, sqsUrl})

if (!sqsUrl) {
logger.error("Notifications SQS URL not found in environment variables")
Expand All @@ -73,7 +73,7 @@ export async function pushPrescriptionToNotificationSQS(

for (const batch of batches) {
const entries = batch
.filter((item) => updateStatuses.includes(item.Status))
.filter((item) => updateStatuses.includes(item.Status.toLowerCase()))
// Build SQS batch entries with FIFO parameters
.map((item, idx) => ({
Id: idx.toString(),
Expand All @@ -92,7 +92,7 @@ export async function pushPrescriptionToNotificationSQS(
}

logger.info(
"Notification required. Pushing prescriptions with deduplication IDs",
"Notification required. Pushing prescriptions to the notifications SQS with the following SQS message IDs",
{deduplicationIds: entries.map(e => e.MessageDeduplicationId), requestId}
)

Expand Down
6 changes: 3 additions & 3 deletions packages/updatePrescriptionStatus/tests/testSqsClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe("Unit tests for pushPrescriptionToNotificationSQS", () => {

// It logs the initial push attempt, but never actually sends
expect(infoSpy).toHaveBeenCalledWith(
"Pushing data items up to the notifications SQS",
{count: data.length, sqsUrl: process.env.NHS_NOTIFY_PRESCRIPTIONS_SQS_QUEUE_URL}
"Checking if any items require notifications",
{numItemsToBeChecked: data.length, sqsUrl: process.env.NHS_NOTIFY_PRESCRIPTIONS_SQS_QUEUE_URL}
)
expect(mockSend).not.toHaveBeenCalled()
})
Expand Down Expand Up @@ -110,7 +110,7 @@ describe("Unit tests for pushPrescriptionToNotificationSQS", () => {
})

expect(infoSpy).toHaveBeenCalledWith(
"Notification required. Pushing prescriptions with deduplication IDs",
"Notification required. Pushing prescriptions to the notifications SQS with the following SQS message IDs",
expect.objectContaining({requestId: "req-789", deduplicationIds: expect.any(Array)})
)
expect(infoSpy).toHaveBeenCalledWith(
Expand Down