arithmetric / aws-lambda-ses-forwarder

Serverless email forwarding using AWS Lambda and SES
MIT License
1.7k stars 450 forks source link

[Curiosity] Why are emails stored in S3? #120

Closed jpiabrantes closed 4 years ago

jpiabrantes commented 4 years ago

Why not just forward the emails? Why storing them in S3 is important?

nastevens commented 4 years ago

@jpiabrantes Check out the documentation page for AWS (SES) regarding the lambda function - the lambda doesn't actually receive the entire message, it only receives metadata about the message as stored in S3. AFAIK the only method for actually receiving (and therefore forwarding) messages with SES is to allow the message to be stored in S3, and then act on the message after the fact using either a Lambda or another service listening via SNS events. I'm surprised that SES doesn't offer a "forward" action by default but 🤷‍♂

There's probably another question to be asked about why the emails are not deleted from S3 after being forwarded, and my guess is that it's just safer that way. At least with this case if things go badly, you still have a copy that you can access. S3 lifecycles are really easy to set up through the console though, so if you wanted to prevent your bucket from getting too big, you could set a lifecycle to delete messages after X number of days.