Learn how to receive and handle email with Amazon SES, Amazon S3, Amazon Lambda (P2)

Tram Ho

Continuing the content of learning about the mechanism of receiving and processing mail with amazon SES, S3, Lambda, today we will continue to learn about Amazon S3 and Amazon Lambda.

Amazon S3

Amazon Simple Storage Service (Amazon S3) is an object storage service that provides scalability, data availability, security, and industry-leading performance. This means customers of all sizes and sectors can use this service to store and protect any amount of data for a variety of use cases, such as websites, applications. mobile, backup and restore, storage, enterprise applications, IoT devices, and data analysis. Amazon S3 provides easy-to-use management features, so you can organize data and configure customized access controls to meet specific requirements of businesses, organizations, and requirements. about compliance. Amazon S3 is designed to ensure 99.999999999% (11 9’s) durability and data storage of millions of applications for companies around the world.

Amazon Lambda

AWS Lambda is a computing service that allows you to run code without providing or managing servers. AWS Lambda only executes your code when needed and automatically scales, from a few requests per day to thousands per second. You only pay for the computation time you consume – there’s no charge when your code doesn’t run. With AWS Lambda, you can run code for almost any kind of application or backend service – all with zero administration. AWS Lambda runs your code on highly available computing infrastructure and performs all administration of computational resources, including server and operating system maintenance, power supply, and auto-opening. broad, code monitoring and logging. All you need to do is provide your code in one of the languages ​​that AWS Lambda supports. You can use AWS Lambda to run your code to respond to events, such as data changes in the Amazon S3 group or the Amazon DynamoDB table; to run your code to respond to HTTP requests with Amazon API Gateway; or call your code with API calls made using the AWS SDK. With these capabilities, you can use Lambda to easily build data processing triggers for AWS services like Amazon S3 and Amazon DynamoDB, handle streaming data stored in Kinesis, or Create your own terminal that works at AWS scale, performance and security. You can also build non-server applications that include functions triggered by events and automatically deploy them using CodePipeline and AWS CodeBuild. For more information, see AWS Lambda Application. For more information about the AWS Lambda implementation environment, see AWS Lambda Runtimes.

Configure settings for Amazon Lambda and Amazon S3 to handle mail

In the previous section, we installed Amazon SES after receiving the mail, we will save that mail to s3, so in this section of course we first have to create a s3 bucket for SES to save mail. ? . To create a s3 bucket, you need to go to the s3 management section and select Create bucket :

Note: The bucket name is the s3 name we set up in Amazon SES.

After successfully setting up the Amazon SES and creating the Bucket S3, when entering the newly created bucket s3, we will see

So we have successfully set up the mail to be saved to s3. Next, we need to set up Lambda to read mail from s3. The first step to using Lambda is to create a Function . Function can be understood as a place where we save the code we handle and a place to listen and handle events of Lambda:

After successfully creating a Lambda Function, we need to pay attention to the two most important parts. The first is where to set up events for other services that can trigger a Lambda Function called a Designer

Here we can easily set the function that can be triggered from any event by clicking Add Trigger . We need to listen from s3 so we will definitely choose s3 as a condition to trigger Lambda Function.

Note: We have to initialize s3 and Lamda function in the same region before they can hear each other.

Thus, we have completed the setup step so that whenever s3 receives new mail, s3 will send that mail data to the Lambda Function and the next is to create a processing flow for data sent from s3. This is the second important part of the Lamda Function called the Function Code .

Here we will use our code to handle the code sent to s3.

Thus we have completed the setup of receiving mail processing with Amazon SES, S3 and Lambda.

https://viblo.asia/p/tim-hieu-co-che-nhan-va-xu-ly-email-voi-amazon-ses-amazon-s3-amazon-lambda-p1-4dbZNpGL5YM

Share the news now

Source : Viblo