Serverless email sending using lambda
OBJECTIVE: To send emails using Lambda to emails present in the DynamoDB table items.
Services Used for sending emails:
I have used 3 services to send emails
1)Amazon Lambda
2)Amazon SES
3)Amazon DynamoDB
Understanding the Services:
1)AWS Lambda:
AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. Therefore, the user/customer doesn’t need to worry about which AWS resources to launch, or how to manage them. Instead, the user needs to put the code on Lambda, and it runs.
In AWS Lambda the code is executed based on the response of events in AWS services such as add/delete files in S3 bucket, HTTP request from Amazon API gateway, etc. However, Amazon Lambda can only be used to execute background tasks. AWS Lambda function helps you to focus on your core product and business logic instead of managing operating system (OS) access control, OS patching, right-sizing, provisioning, scaling, etc.
2)AWS DynamoDB:
Amazon DynamoDB is a fully managed NoSQL database service provided by Amazon Web Services (AWS). It is designed to provide fast and predictable performance with seamless scalability. DynamoDB is a serverless database, which means that you don't need to provision or manage any servers, and it automatically scales up or down to handle the incoming traffic. This makes it a great choice for applications that require low-latency, high-performance data access.
3)AWS SES:
AWS SES (Simple Email Service) is a cloud-based email service provided by Amazon Web Services (AWS) that enables businesses and developers to send and receive email using a highly scalable and reliable email platform. AWS SES provides a simple, cost-effective way to send and receive email, whether it is marketing messages, transactional messages, or notifications. With AWS SES, you can send and receive email with your own email address, or you can use an Amazon-provided email address.
AWS SES is designed to be highly scalable and reliable, so it can handle a high volume of email traffic without interruption. It is also designed to be flexible, allowing you to integrate it with other AWS services, such as Lambda and SNS, and with third-party applications.
Recommended by LinkedIn
Architecture:
Procedure:
Step 1: Login to the AWS console and open the SES(Simple Email Service) service and add the required identities.
Step 2: Go to the DynamoDB console and create a DynamoDB table with email id as the partition key.
Step 3: Add items into the DynamoDB table.
Step 4: Go to Lambda function console and create a Lambda function in python.
Step 5: Wirte a funtion for sending the email and anothe funtion for sending the email to the items present in the DynamoDB table.
Step 6: Deploy the lambda function and click on Test.
The email will be sent to the items present in the DynamoDB table.
OUTPUT:
Resources Required:
References: https://aws.amazon.com/blogs/compute/maintaining-a-healthy-email-database-with-aws-lambda-amazon-sns-and-amazon-dynamodb/