Amazon API Gateway REST API to AWS Lambda and Amazon SES

API Gateway REST API → AWS Lambda → Amazon SES

Send an email with Amazon SES from an AWS Lambda function behind an Amazon API Gateway REST API.

This pattern deploys an Amazon API Gateway REST API with a GET method, defined in an OpenAPI file. The method invokes an AWS Lambda function, which uses the AWS SDK for Python (Boto3) to send an email with a text and an HTML body through Amazon SES in the function's own Region.
You set the sender and recipient addresses as stack parameters. The function can only send from the sender address, and to the recipient address. Verify the sender in Amazon SES before you deploy. In the SES sandbox, verify the recipient too.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/api-lambda-ses/python/sam

Deploy

sam buildsam deploy --guided --parameter-overrides SENDER=sender@example.com RECIPIENT=recipient@example.com


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Created by:

Himanshu Goyal

Himanshu Goyal

A Serverless Cloud Engineer and technical writer, dedicated to crafting efficient and scalable solutions using AWS services. My expertise in serverless architecture empowers me to create innovative and cost-effective cloud solutions. I enjoy sharing my knowledge with the serverless community through articles and patterns, helping others explore the vast potential of serverless computing.