Aws lambda描述实例超时

我有这个简单的describe实例函数,我试图通过AWS Lambda在nodejs中运行:

var AWS = require('aws-sdk'); AWS.config.region = 'us-east-1'; exports.handler = function(event, context) { console.log("\n\nLoading handler\n\n"); var ec2 = new AWS.EC2(); ec2.describeInstances(function(err, data) { console.log("\nIn describe instances:\n"); if (err) { console.log(err, err.stack); context.done(null, 'Function Finished from error!'); // an error occurred }else { console.log("\n\n" + data + "\n\n"); context.done(null, 'Function Finished with data!'); // successful response } }); }; 

这不会返回任何错误CloudWatch中的唯一输出是这样的:

 2016-03-21T17:01:59.085Z xxxxxxx-xx.... Task timed out after 3.00 seconds 

任何人有任何想法可能是什么问题?

检查此: https : //medium.com/@philippholly/aws-lambda-enable-outgoing-internet-access-within-vpc-8dd250e11e12#.2sdn5oyd1

如果你在VPC,你不能访问互联网了!

您应该configurationNAT以启用lambda中的传出Internet访问。

我也面临同样的问题..我增加超时(Lambda – >configuration – >高级设置)从3秒到5秒,它工作正常。

确保执行angular色具有EC2权限并尝试使用:

context.fail()context.succeed()

VS

context.done()