SES Event Source

I need to create an SES triggered function. It’s a typical SES design; a rule dumps the incoming email to S3 and then triggers a function. I know I can create the rule with CloudFormation but not sure how I’d define the event trigger in serverless.yml.

This is a good question. I’m not sure you can use the baked in events.

However you could use the plugin to listen to those s3 buckets where the emails are dumped.

Out of curiosity, what does the cloudformation for this look like?

@DavidWells, thanks for the response.
Yesterday I was able to use the ‘AWS SES receive emails and process body’ example and add an SES rule in the Resources section (see below.) Only problem is that I can’t auto-create the S3 bucket Action because the S3 bucket doesn’t exist at the time the CloudFormation resources are created. So this gets me closest to an automated solution; I just have to go into the SES rule and add the S3 bucket action. When I remove the stack, I just have to first delete all content from the bucket and then Serverless removes it all. If I could create the bucket in the Resources section without screwing up the Event-based creation, I’d have a complete solution.

Type: AWS::S3::BucketPolicy

Type: AWS::SES::ReceiptRule
RuleSetName: default-rule-set
Name: {self:custom.sesRuleName} Enabled: true Recipients: - Fn::Join: ['', ["{self:custom.sesRuleName}", ‘’] ]
ScanEnabled: true
- StopAction:
Scope: RuleSet
# S3Action:
# BucketName: ${self:custom.bucketRef}