I was wondering if I can send a message to SQS queue and subscribe an SNS topic to it to trigger a lambda for sending an email.
SQS -> SNS -> (Lambda) -> SES
I know SNS messages can be sent to SQS but I'm curious if the other way around is possible
Best Answer
One thing I did was to create a CloudWatch alarm on
ApproximateNumberOfMessagesVisible
(>= 1 for 5 minutes
) for the SQS queue. The alarm publishes to an SNS topic that triggers the lambda function. The lambda function loops until it clears the queue.It can take up to 5 minutes to trigger from the alarm, but it works fantastically for batch-scheduled tasks without needing to poll the queue. (Alarm granularity is 5 minutes for active queues.)