Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aws lambda describe instances time out

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?

like image 918
Tomas Avatar asked Mar 21 '16 17:03

Tomas


2 Answers

I also faced same issue.. I increased timeout( Lambda --> Configuration --> Advanced Settings) from 3 seconds to 5 seconds and it worked fine.

like image 120
Deepak Singhal Avatar answered Sep 24 '22 22:09

Deepak Singhal


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

If you are in VPC, you can't access Internet anymore!

You should configure NAT to enable outgoing internet access in lambda.

like image 32
Seung gi Lim Avatar answered Sep 22 '22 22:09

Seung gi Lim