Part 6: Create an AWS Lambda Function - connect-group/terraform-aws-ses-dashboard GitHub Wiki
Now that all of the components are in place, you can create a Lambda function. The function creates an HTML dashboard and notifies you by email when that dashboard is updated.
To create a new AWS Lambda function
-
Download sesreport.zip from https://github.com/awslabs/aws-support-tools/raw/master/SES/SESReports/sesreport.zip.
-
Sign in to the AWS Management Console and open the AWS Lambda console at https://console.aws.amazon.com/lambda/.
-
Choose Create function.
-
Choose Author from scratch.
-
On the Basic information page, make the following selections:
- For Name, type a name for the function.
- For Role, select Choose an existing role.
- For Existing role, choose the role you created in Part 4: Create AWS Identity and Access Management Policies and Roles.
Choose Create function.
-
Under Function code, for Code entry type, choose Upload a .ZIP file.
-
Under Function package, choose Upload. Upload sesreport.zip.
-
Under Environment variables, specify the following keys and values:
Keys and Values
-
QueueURL
- The URL of the Amazon SQS queue you created in Part 2: Create a Queue in Amazon Simple Queue Service.
- https://sqs.us-east-1.amazonaws.com/999623213###/sample-queue-name
-
Region
- The AWS Region in which you created the Amazon SNS topic in Part 1: Create a Topic in Amazon Simple Notification Service.
- Example:
us-east-1
-
ToAddr
- [Optional] The email address that will receive the bounce and complaint report.
- Example:
[email protected]
-
SrcAddr
- [Optional] The email address that will send the bounce and complaint report.
- Example:
[email protected]
-
BucketName
- The name of the Amazon S3 bucket you created in Part 3: Create an Amazon Simple Storage Service Bucket.
- Example:
sample-s3-bucket
-
BucketPrefix
- [Optional] If you want to save the dashboards in a folder in the Amazon S3 bucket, specify the path here. The path you specify must end with a forward slash (/).
- Example:
SES/reports/
-
Under Basic settings, make the following selections:
- For Memory (MB), choose 512.
- NOTE: If you think you will receive more than 5,000 bounces and complaints per day, specify a Memory value of 1024 MB or greater. If you think you will receive more than 10,000 bounces and complaints per day, specify a Memory value of 1536 MB or greater.
- For Timeout, select 5 minutes.
- For Memory (MB), choose 512.
-
Choose Save and test.
-
On the Configure test event window, for Event name, type a name, and then choose Create.
-
Proceed to Part 7: Test the AWS Lambda Function.