Skip to content

Commit 8a8745f

Browse files
committed
WIP: schedule import_ballots with SQS
1 parent 989a201 commit 8a8745f

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

sam-template.yaml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,12 @@ Resources:
9999
CreatedVia: CloudFormation
100100
Events:
101101
ImportPeopleRecentlyUpdated:
102-
Type: Schedule # More info about API Event Source: https://github.com/aws/serverless-application-model/blob/master/versions/2016-10-31.md#schedule
102+
Type: SQS
103103
Properties:
104-
Schedule: cron(*/5 * ? * * *) # using the ? as you cannot use * wildcard for both day-of-month and day-of-week field. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions
105-
Name: import-people-recently-updated
106-
Description: Update all people updated in YNR recently
107-
Input: '{"command": "import_people", "args": ["--recently-updated"]}'
108-
RetryPolicy:
109-
MaximumRetryAttempts: 0
104+
Queue: !Ref WCIVFJobsQueue
105+
FilterCriteria:
106+
Filters:
107+
- Pattern: '{"command": ["import_people"], "args": ["--recently-updated"]}'
110108
DeleteDeletedPeople:
111109
Type: Schedule # More info about API Event Source: https://github.com/aws/serverless-application-model/blob/master/versions/2016-10-31.md#schedule
112110
Properties:
@@ -463,7 +461,7 @@ Resources:
463461
HostedZoneName: !Sub "${Domain}."
464462
Name: !Sub "www.${Domain}."
465463
Type: A
466-
464+
# SQS queue for running background jobs, with a dead letter queue for failed jobs
467465
WCIVFJobsDlq:
468466
Type: AWS::SQS::Queue
469467
Properties:
@@ -499,7 +497,20 @@ Resources:
499497
Service: events.amazonaws.com
500498
Action: sqs:SendMessage
501499
Resource: !GetAtt WCIVFJobsQueue.Arn
502-
500+
# Rules to trigger background jobs
501+
ImportPeopleRecentlyUpdatedRule:
502+
Type: AWS::Events::Rule
503+
Properties:
504+
Name: import-people-recently-updated
505+
Description: Update all people updated in YNR recently
506+
ScheduleExpression: cron(*/5 * ? * * *)
507+
State: ENABLED
508+
Targets:
509+
- Id: WCIVFJobsQueue
510+
Arn: !GetAtt WCIVFJobsQueue.Arn
511+
SqsParameters:
512+
MessageGroupId: wcivf-jobs
513+
Input: '{"command": "import_people", "args": ["--recently-updated"]}'
503514
Outputs:
504515
WCIVFControllerFunctionArn:
505516
Description: "WCIVF Controller Lambda Function ARN"

0 commit comments

Comments
 (0)