Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide to using AWS Lambda with AWS Simple Email Service #99

Merged
merged 3 commits into from
Nov 7, 2018
Merged

Conversation

finnhodgkin
Copy link
Contributor

@finnhodgkin finnhodgkin commented Jul 13, 2017

** Probably not ready for merge because the advice on permissions for S3 is a little dubious... Currently we just open it to anyone and everyone **

Adds a section on Amazon Simple Email Service

Relates to #97 #98

@codecov
Copy link

codecov bot commented Jul 13, 2017

Codecov Report

Merging #99 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #99   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           5      5           
  Lines         230    230           
=====================================
  Hits          230    230

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf0aef1...ba7b80a. Read the comment docs.

@codecov
Copy link

codecov bot commented Jul 13, 2017

Codecov Report

Merging #99 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #99   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           5      5           
  Lines         230    230           
=====================================
  Hits          230    230

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf0aef1...96fff16. Read the comment docs.

@ZooeyMiller ZooeyMiller requested a review from nelsonic July 13, 2017 17:37
@finnhodgkin finnhodgkin changed the title [WIP] Guide to using AWS Lambda with AWS Simple Email Service Guide to using AWS Lambda with AWS Simple Email Service Jul 13, 2017
@nelsonic
Copy link
Member

@finnhodgkin only just saw this. 😮
(if PR isn't assigned to me then I don't get a notification for it...) 🔕 😞

@nelsonic nelsonic self-assigned this Jul 16, 2017
README.md Outdated
@@ -77,6 +77,7 @@ something to S3 on each execution cycle you could rack up the bill!
* [Use the callback parameter with node v4.3](#the-callback-parameter)
* [Trigger a Lambda function using an event from DynamoDB](#triggering-a-lambda-function-using-an-event-from-dynamodb)
* [Trigger a Lambda function using the Simple Notification System](#trigger-a-lambda-function-using-the-simple-notification-system)
* [Trigger a Lambda function when an email comes in to the AWS Simple Web Service](#trigger-a-lambda-function-when-an-email-is-received-by-amazon-simple-email-service)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWS Simple Web Service >> AWS Simple Email Service (SES)

#### Save the email to S3
Go back to the rule set you created for your Lambda function. Add a new action to it, this one should be an S3 action, with the bucket you want to use selected. This will save the email to S3. Make sure this action is positioned **above** your Lambda function:

![ses management console - google chrome_006](https://user-images.githubusercontent.com/22300773/28177094-a0e16bfc-67f1-11e7-8676-feabc437295f.png)
Copy link
Member

@nelsonic nelsonic Jul 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to avoid having other tabs in the screenshot as it's "noisy".
image
(keep the focus on the task you are currently performing to avoid distracting/confusing your reader) 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have access to Photoshop here and the Linux alternatives are a bit of a pain to use. Happy to update this when I get home from my holiday 🍹

README.md Outdated
"Action": [
"logs:CreateLogStream",
"logs:PutLogEvents",
"s3:*" // This allows all S3 functions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fairly certain these comments aren't allowed. (which is a shame because they are instructive ...)


So now when we receive an email it is save to S3 and a function is triggered. Next we need we need to hook the two up so our Lambda function reads the saved file, and saves the body in a nice readable way.

#### Save the body to S3 using AWS Lambda
Copy link
Member

@nelsonic nelsonic Jul 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we save all incoming emails it's possible for a SPAMer to flood our Lambda and cause us to waste loadz-a-money on S3 writes ...
image
$0.05 per 1,000 writes to S3 might not sound like a lot, but it will add up if you consider the volume of spam sent/received. (if you use GMail you won't realise it because Google has amazing filters, but an "un-protected" email address will get hundreds and a reasonably popular domain will get thousands of SPAM emails per day)

Fun Fact: Over 50% of email is SPAM see: https://www.statista.com/statistics/420391/spam-email-traffic-share/
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a note with some of the above comment before the S3 section. Should hopefully help to deter people from leaving this set up on their own accounts.

A better exercise could be to process the email with Lambda before saving to S3 so we could run something more interesting like a check for a certain keyword or something like that.

Copy link
Member

@nelsonic nelsonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@finnhodgkin & @ZooeyMiller so far looks good. just need to update the TOC then should be ready to merge. thanks! 🎉

@codecov
Copy link

codecov bot commented Nov 1, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@bf0aef1). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             master    #99   +/-   ##
=======================================
  Coverage          ?   100%           
=======================================
  Files             ?      5           
  Lines             ?    230           
  Branches          ?      0           
=======================================
  Hits              ?    230           
  Misses            ?      0           
  Partials          ?      0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf0aef1...2893433. Read the comment docs.

@finnhodgkin finnhodgkin assigned nelsonic and unassigned finnhodgkin Nov 1, 2018
Copy link
Member

@nelsonic nelsonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@finnhodgkin thank you for making the time to complete this PR even though it's not your current focus! I really appreciate it! 🥇
Hope you have a great day! ☀️

@nelsonic nelsonic merged commit 1a1448c into master Nov 7, 2018
@nelsonic nelsonic deleted the aws-ses branch November 7, 2018 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants