Reputation: 1141
I have this simple describe instances function that I'm trying to run in nodejs via AWS Lambda:
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
}
});
};
This does not return me any errors the only output in CloudWatch is this:
2016-03-21T17:01:59.085Z xxxxxxx-xx.... Task timed out after 3.00 seconds
Anyone have any idea what could be the problem?
Upvotes: 15
Views: 7351
Reputation: 46
If you are in VPC, you can't access Internet anymore!
You should configure NAT to enable outgoing internet access in lambda.
Upvotes: 3
Reputation: 10876
I also faced same issue.. I increased timeout( Lambda --> Configuration --> Advanced Settings) from 3 seconds to 5 seconds and it worked fine.
Upvotes: 11
Reputation: 345
Make sure the execution role has EC2 permissions and try using:
context.fail()
or context.succeed()
vs
context.done()
Upvotes: 2