dwyl / learn-aws-lambda

✨ Learn how to use AWS Lambda to easily create infinitely scalable web services
1.05k stars 202 forks source link

Add "How to save the body of an email to S3" #98

Open ZooeyMiller opened 7 years ago

ZooeyMiller commented 7 years ago

With regards to dwyl/apprenticeship#13 (comment) we want to add a section to this repo explaining how to save the body of an email to S3 when an email is received in SES.

ZooeyMiller commented 7 years ago

We've been struggling with "access denied" when trying to upload a text file to our s3 bucket (at the moment we're just trying to upload a string of text to s3, and once we've gotten that down look at uploading the email body).

We got it working by giving all Authenticated AWS users write access to our bucket as detailed here: https://stackoverflow.com/questions/35589641/aws-lambda-function-getting-access-denied-when-getobject-from-s3 but are now trying to set it up properly so that only specific users can have write access, but this is proving difficult.

ZooeyMiller commented 7 years ago

We've been bashing our heads against the wall a bit with the Access Denied stuff so thought a break from it was in order, so we're going to work on trying to get the actual email saved to S3, and deal with the permission kerfuffle later when we've had some time to cool off.

ZooeyMiller commented 7 years ago

It turns out that when we recieve emails with SES it hasn't been triggering our lambda function, so we tried to get it to just straight trigger a S3 store of everything about the email (not just the body), which weirdly worked straight away.

We can't work out why it is working to trigger an S3 upload directly but not a lambda function. The internet here is cutting out every 30 seconds so we're going to break for lunch and hope that the internet is working when we're back to try to debug this.

ZooeyMiller commented 7 years ago

for some reason redoing the SES ruleset, and disabling virus protection made it work. We're wondering if there was something wrong with the initial set up that we didn't notice that we fixed by redoing it?

We're now re-enabling virus protection to see if that actually was the problem.

EDIT: note that there was 1.25 hrs during this time that we were on breaks, so the t4h time estimate still holds true.

ZooeyMiller commented 7 years ago

Well, we re-enabled virus protection and it still works so... :woman_shrugging: