# SES Event Source

**URL:** <https://forum.serverless.com/t/ses-event-source/7656>\
**Category:** Serverless Framework\
**Created:** [March 12, 2019, 11:25pm UTC](https://forum.serverless.com/t/ses-event-source/7656 "2019-03-12T23:25:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shunyun-bp](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@shunyun-bp](https://forum.serverless.com/u/shunyun-bp)\
**Post date:** [March 12, 2019, 11:25pm UTC](https://forum.serverless.com/t/ses-event-source/7656/1 "2019-03-12T23:25:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DavidWells](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/davidwells/32/201_2.png) [@DavidWells](https://forum.serverless.com/u/DavidWells)\
**Post date:** [March 14, 2019, 5:12pm UTC](https://forum.serverless.com/t/ses-event-source/7656/2 "2019-03-14T17:12:32Z")

</div>

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

However you could use the [https://www.npmjs.com/package/serverless-plugin-existing-s3](https://www.npmjs.com/package/serverless-plugin-existing-s3) plugin to listen to those s3 buckets where the emails are dumped.

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

---

<div class="post-metadata">

**Author:** ![shunyun-bp](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@shunyun-bp](https://forum.serverless.com/u/shunyun-bp)\
**Post date:** [March 14, 2019, 5:32pm UTC](https://forum.serverless.com/t/ses-event-source/7656/3 "2019-03-14T17:32:04Z")

</div>

@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.

resources:  
Resources:  
S3EMailBucketPermissions:  
Type: AWS::S3::BucketPolicy  
…  
ReceiptRule:  
Type: AWS::SES::ReceiptRule  
Properties:  
RuleSetName: default-rule-set  
Rule:  
Name: {self:custom.sesRuleName} Enabled: true Recipients: - Fn::Join: ['', ["{self:custom.sesRuleName}", ‘@acme.com’] ]  
ScanEnabled: true  
Actions:  
- StopAction:  
Scope: RuleSet  
# S3Action:  
# BucketName: ${self:custom.bucketRef}
