A lambda function that sends sns notifications about emails to azure-log-analytics
SES is capable of sending reports about email delivery (deliveries, bounces, rejects) to SNS. However, there's no built in way to pipe these reports into something like azure-log-analytics. This Lambda function bridges the gap and allows to send the reports to ES.
+-------+ +-------+ +--------+ +---------------------+
| SES +---> | SNS +---> | Lambda +---> | Azure Log Analytics |
+-------+ +-------+ +--------+ +---------------------+
Lambda requires you to include any npm dependencies your function needs with the bundle. Prepare the zip bundle:
$ npm install --production
$ zip -r lambda-bundle.zip *
Then upload the bundle directly to Lambda through the upload button
There are couple of steps that need to be done on AWS console to make this work:
- Create a topic on SNS for the email deliveries.
- Set up notifications for you SES email address. Set these notifications to be sent to the topic you created.
- Create a lambda function with a trigger for SNS. Set the topic on that trigger to the topic you created.
- Subscribe to the topic and set Lambda as the destination for notifications.
The function expects several environment variables to be set:
WORKSPACEID
- WorkspaceID is the unique identifier for the Log Analytics workspace.SHAREDKEY
- Primary Key ID of Log Analytics workspace.APIVERSION
- The version of the API to use with this request. Currently, it's2016-04-01
.PREFIX
- The index name prefix. For example, ifPREFIX='aws_ses_emails'
Note: Index name do not allow hyphen(-).