Amol Borkar
Amol Borkar

Reputation: 2599

Amazon SES not triggering lambda function

I'm working on a lambda function which needs to process .csv files attached to incoming emails. I already have my domain verified with Amazon SES. I've created a new ruleset with just one rule for triggering the lambda. I've added one email in recipient condition for this rule and gave SES the permission to invoke the lambda.

But this is not working, the lambda is not getting invoked no matter how many emails I receive. Am I missing anything here?

Upvotes: 0

Views: 590

Answers (1)

pomSense
pomSense

Reputation: 69

Although additional information would be helpful, the below steps should cover most scenarios:

  • Is your domain verified with MX records setup at your DNS provider (you must own the domain you are receiving emails to. I.e. @gmail.com won't work)
  • Do you have the MX records as well for ses? The MX record must be for the exact domain (or subdomain) you are using to receive the emails. For my case, it is ses.mycompany.com. Here is the value of the MX record if your lambda and ses is in us-east-1. Change that to your specific region. List of supported regions
   10 inbound-smtp.us-east-1.amazonaws.com

IMPORTANT: Straight from AWS docs: "...all of the AWS resources that you use for receiving email with Amazon SES have to be in the same AWS Region as the Amazon SES endpoint. For example, if you use Amazon SES in the US West (Oregon) Region, then any Amazon SNS topics, AWS KMS keys, and Lambda functions that you use also have to be in the US West (Oregon) Region. Similarly, to receive email with Amazon SES within a Region, you have to create an active receipt rule set in that Region."

  • You also need to give ses permissions to invoke the lambda. You can do this once you create the rule set or if you're using a framework like Serverless, you can provide it under the resources as such
resources:
  Resources:
    GiveSESPermissionToInvokeMyfunctionLambdaFunction:
      Type: AWS::Lambda::Permission
      Properties:
        FunctionName: { "Fn::GetAtt": [ "MyfunctionLambdaFunction", "Arn" ] }
        Principal: ses.amazonaws.com
        Action: 'lambda:InvokeFunction'
        SourceAccount: { Ref: AWS::AccountId }
  • Finally, I would recommend deleting your rule and recreating it after you have done the verification.

Upvotes: 1

Related Questions