aws lambda SES 函数超时

aws lambda SES function timeout

我正在使用 nodejs 8.1 版和无服务器框架

在我的 serverless.yml 我有:

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

我的 lambda 看起来像这样:

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();
}

我不明白为什么从不执行 getIdentity 函数。 函数超时退出。

您正在等待异步调用的响应,很可能您没有收到响应。检查 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 以帮助确定权衡。