Trigger a Typescript AWS Lambda on Receiving an Email with SES
How to trigger a Typescript AWS Lambda function when you receive an email in AWS SES
In this blog post, we'll discuss how to trigger a Typescript AWS Lambda function when you receive an email in AWS SES. We'll be using SST V2 in this example, but it's easily convertible to CDK if needed.
As a prerequisite, you'll need to set up a verified identity and inbound rule in Route 53 for this to work. The docs found here are pretty straightforward.
Infrastructure as Code (IAC)
First, we need to set up the stack and IAC for the inbound rule and function.
Ensure to change the inbound domain and function path to fit your project. This will route all traffic from the domain to your lambda function.
We also need to go into the console and mark this inbound rule as active. Note you can only have one active rule per region per account - but nothing is stopping you from adding more domains to the recipients array. We'll cover how to route to your desired operation below.
AWS Lambda Typescript Handler
Next, we need to set up the handler to perform whatever operation we need.
With this function, we can perform whatever operation we need within our Typescript code.
Thanks for reading!