Do you need:
- A simple way to send emails from your frontend app
- Text and HTML email templates that live in S3
- A decoupled approach to handling email sending in your backend using a queue
- A way to find and retry failed emails
This package deploys everything you need to trigger an email being sent via an API Gateway request. The payload could include your template variables, such as name, email, message, etc.
When the API gets a request, it calls a lambda that fetches the required template from S3 and compiles it to text or html. It then sends the compiled version along in a notification to SNS. A queue in SQS holds the message, where another lambda waits to handle sending to SES.
npm install (this is for build tools)
cd BuildEmailTemplate
npm install (this is the lambda)
Create a bucket and make a folder in it called Templates
. This is where you put HTML/Text templates.
Create a new topic. Note the ARN
for the new topic.
Create an queue. You'll want SNS to subscribe to this Queue. Then use another SNS topic to publish to the queue.
Configure SES like you normally would.
Open lambda-config.js
and configure to your liking based on the options aws-sdk provides for lambdas.
Open sample-iam-policy.json
and copy into a managed policy. Create a new role and attach the policy.
Click 'Trust Relationships' and edit the trust policy. Open sample-iam-trust-policy.json
and copy into a managed policy.
gulp deploy
reads lambda-config.js
, creates a zip, and deploys it to AWS Lambda.
node test.js
has basic integration test coverage.
- Improve SQS integration
- Support more SNS subscriber types and templates
- Provide CloudFormation template that makes the configuration much easier
- One-click deploy script