AWS, Cloud Computing

4 Mins Read

Automate Sending Emails with AWS Lambda, CloudWatch, and Simple Email Service

Voiced by Amazon Polly

Overview

In today’s busy world sending bulk of emails every day to thousands of users is becoming a challenge so to make it easy for the users, AWS provides many services in that one of the services is a simple email service that integrates into any application for bulk email sending and you pay only for what you use.

In this blog, we are going to see how these three services (lambda, CloudWatch, and SES) are used to send automated emails at a specific time. CloudWatch is to set up a Schedule to trigger a lambda function and then it uses SES to send the emails to the users.

Pre-requisites

  • AWS account
  • AWS CLI
  • AWS IAM permissions for required Services

Customized Cloud Solutions to Drive your Business Success

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Architecture Diagram

AD

The architecture diagram above shows how an event is triggered from CloudWatch, captured by a lambda function, and then passed to Amazon SES, which sends emails to the Users.

Step-by-Step guide for Sending Automated Emails

Step 1: Creating IAM Role

Step 2: Creating Lambda Function

Step 3: Creating CloudWatch Events

Step 1: Creating IAM Role

  • In the AWS console search for IAM in the search bar and select the service
  • In that select roles and click on create role
  • Select use cases as Lambda and click on next
  • In permission policies choose CloudWatch full access and SES full access and then click on next
  • Give a suitable name for the role and click on create role
  • Then role will be created.

Step1

Step1b

Step 2: Creating Lambda Function

  • In the AWS console search for Lambda in the search bar and select the service.
  • Provide the name of the function.
  • In the position of runtime, we must choose the language that we want. Here, I am choosing the most recent NodeJS 16.x version.
  • Choose whether to create a new or existing role as the executing role in the following step. I’m choosing the role that I already created in the previous phase.
  • Rest everything. We can keep it optional
  • Select Create a Function.

Step2

  • After the creation of the lambda function, we need to write Lambda code to send an email
  • Next, choose to configure a test event
  • Give a suitable name for the test event and click on create

Step2b

Step2c

Step 3: Creating CloudWatch Events

  • In the AWS console search for CloudWatch in the search bar and select the service.
  • In the left navigation pane, select Event in that select rules and then click on create rule.
  • Next, choose the schedule and click on the Cron expression to set it to a specific time.
  • Select add target and choose the lambda function I’m choosing the function that I already created in the previous phase.
  • Click on configure details.
  • Next, give a name to the rule and rest everything we can keep optional
  • Click on create rule.

Step3

Step3b

Result:

  • Lambda is triggered and sent an email to the users at the scheduled time

Output

Conclusion

By concluding this blog, we have understood how AWS Lambda service runs your code in response to events and SES the cost-effective email service built on the reliable and scalable infrastructure that sends emails or any other content to the users and Amazon CloudWatch which is using simple rules that you can quickly set up, you can match events and route them to one or more target functions.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding AWS Lamda, AWS CloudWatch, AWS SES and I will get back to you quickly.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.

FAQs

1. Can Amazon SES send emails with attachments?

ANS: – Amazon SES service supports many popular content formats, including documents, images, audio & video.

2. Why should I use IAM roles?

ANS: – Using IAM Role is the Security best practice where you can access AWS services by relying on short-term credentials.

WRITTEN BY Chamarthi Lavanya

Lavanya Chamarthi is working as a Research Associate at CloudThat. She is a part of the Kubernetes vertical, and she is interested in researching and learning new technologies in Cloud and DevOps.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!