superphung
superphung

Reputation: 115

aws lambda SES function timeout

I am using nodejs version 8.1 and severless framework

in my serverless.yml I have:

provider:
  name: aws
  runtime: nodejs8.10
  region: eu-west-1
  iamRoleStatements:
  - Effect: "Allow"
    Action:
      - "ses:GetIdentityVerificationAttributes"
    Resource: "*"

and my lambda looks like this:

const AWS = require('aws-sdk');
var ses = new AWS.SES({
  region: 'eu-west-1'
});
module.exports.handler = async (event, context, callback) => {
 context.callbackWaitsForEmptyEventLoop = false;
 let identityVerif = await ses.getIdentityVerificationAttributes({Identities: ['email']}).promise();
}

I don't understand why the getIdentity function is never executed. The function exit with a timeout.

Upvotes: 4

Views: 4370

Answers (1)

bwest
bwest

Reputation: 9834

You're waiting for the response of an async call, and it's likely that you aren't getting one. Check the SES API logs in CloudTrail to make sure that the request is actually being made. It sounds like your lamdba function can't access SES, which would happen if you are running it in a VPC. You would need to add a NAT Gateway to the VPC. Consider moving your lambda outside of your VPC. Here is a guide to help determine the tradeoffs.

Upvotes: 4

Related Questions