1

I'm using AWS SNS to publish various events, and instead of sending an email every time something happens, I'm looking to roll them up into a digest and send them to relevant parties once daily

For bonus points, when sending the digest as an email, I'd like any party to be able to opt out via a one click unsubscribe, just like the regular AWS SNS email subscriptions.

How do people typically accomplish this on the AWS platform? I'm thinking SQS queue perhaps that gets flushed daily to SES, but that requires quite a lot of programming, unless I'm missing something? I'm open to third party solutions, if there is one.

hendry
  • 9,725
  • 18
  • 81
  • 139

2 Answers2

1

You will need to program this solution. It would be something like:

  • Store messages in a database
  • Once per day group messages by user and send an email
  • Provide an unsubscribe web page either on an EC2 server, or serverless via AWS Lambda and AWS API Gateway. Programming required.
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Why is AWS SQS unsuitable out of interest? – hendry Apr 16 '18 at 03:22
  • 1
    You wish to group message by user to send out a daily digest. There is no ability to grab all the messages in an SQS queue that related to a single user. – John Rotenstein Apr 16 '18 at 05:25
  • There is the [filter policy](https://docs.aws.amazon.com/sns/latest/dg/sns-message-filtering.html) feature that actually does allow to only receive a subset of messages. But as John said, that wouldn't grab *all* the messages in a queue. It would only filter them as they are received. – Shadi Oct 02 '19 at 07:11
1

We built something very similar. Here is how we accomplished it:-

  1. The emails we want to batch up were saved in the database
  2. We setup a CloudWatch Event to hit an SNS topic every day at 8am
  3. The only subscription to that topic was a HTTP endpoint

On invocation of the HTTP endpoint we would then begin a background process that would send out a digest of emails. We did debate having the CloudWatch Event push directly to a SQS queue, but opted for the HTTP endpoint as we prefer pushing over pulling.

Hope that helps!