New serverless pattern - EventBridge Scheduler to Lambda with Dual DLQs#2981
Conversation
|
|
||
| log_info('Scheduled function invoked by EventBridge Scheduler', {'event': event}) | ||
|
|
||
| execution_time = datetime.utcnow().isoformat() + 'Z' |
There was a problem hiding this comment.
If I remember right, datetime.utcnow() is deprecated in Python 3.12. You may want to use datetime.now(datetime.UTC) or alternate function
| print('\nSIMULATING FAILURE') | ||
| print('This will trigger:') | ||
| print('1. Lambda async retry (up to 2 times)') | ||
| print('2. After all retries fail - Event sent to Lambda Execution DLQ') |
There was a problem hiding this comment.
Use of logging or aws_lambda_powertools.Logger module is preferred instead of print()
| QueueName: !GetAtt LambdaExecutionDLQ.QueueName | ||
|
|
||
| # Dead Letter Queue for Lambda execution failures | ||
| LambdaExecutionDLQ: |
There was a problem hiding this comment.
Both SQS DLQ queues do not configure server-side encryption. DLQ messages may contain event payloads with sensitive data. SQS supports SSE-SQS (managed) or SSE-KMS encryption. It is recommended to add SqsManagedSseEnabled: true to both queue definitions to showcase security aspect in pattern
| Globals: | ||
| Function: | ||
| Timeout: 30 | ||
| Runtime: python3.12 |
There was a problem hiding this comment.
AWS Lambda supports python3.14 as latest version at the time of writing this, I'd recommend updating Function version to latest available.
Issue #, if available:
#2982
Description of changes:
This pattern demonstrates EventBridge Scheduler's failure handling capabilities through dual Dead Letter Queues (DLQs). One DLQ captures Lambda execution failures (code errors, timeouts), while the other captures scheduler invocation failures (permissions, throttling, resource not found).
Pattern includes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.