This example illustrates a scenario where an AWS SQS Queue, AWS SES and a Lambda function, work together to deliver messages from SQS to SES. The code given in "sqs-microservice-python3.py" file contains the Lambda code to be run in Python3 environment.
This code is to adhere the Limitations in SES when sending multiple emails at the same time. Limitations in AWS SES
Step 1: Add the code to a Lamda function running on Python3
Step 2: In the code, change the respective parameters to support your requirement
- QUEUE_URL: AWS SQS Queue URL: eg: 'https: //sqs.region.amazonaws.com/endpoint value/queue_name'
- LAMBDA_RUN_TIME: Time the Lambda will be runnig before shutting down. (max 5 mins)
- THRESHOLD: The time in mili-seconds to keep within a second, to ensure SES limitations are not exceeded.
- CHARSET: charset supported in messages
- THREAD_COUNT: number of threads to be invoked concurrently (since lambda is running on two cores, 4 thread is ideal)
- SES_SEND_RATE: the limitation that SES has, on sending multiple emails at once.
Step 3: Add CloudWatch rules to invoke the Lambda function every few minutes