mentum / lambdaws

Deploy, run and get results from Amazon AWS Lambda in a breeze

Home Page:http://mentum.github.io/lambdaws

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

on new Function upload ETIMEDOUT

ramonck opened this issue · comments

Hi,

On a new simple function upload to AWS Lambda I've the following error with your library.

{ [Error: Function upload to AWS Lambda timed out.] code: 'ETIMEDOUT' }

Please verify why I cannot use it to upload functions to Lambda, I'm utilizing the same function with another library and it's working fine.

Best Regards

@ramonck I'll look it up today. Can you paste me your function ?

@ramonck everything seems fine on my side,

To reproduce the error, I needed to remove credentials in my config object. Make sure you specify your credentials AND a role with full access to LAMBDA and SQS.

I'll improve the docs to avoid future confusions.

Sure,

Here's the full script with the function.

var lambdaws  = require('lambdaws'),
    lambdawsC = lambdaws.create;

lambdaws.config({
  credentials: {
    accessKey: 'MYACCESSKEY',  // string, AWS AccessKeyId.
    secretKey: 'MYSECRETKEY',  // string, AWS AccessKeySecret.
  },
  role: 'arn:aws:iam::999999999999999:role/lambda_exec_role',  // string, AWS ARN. Must have full access to SQS.
  region: 'us-east-1'
});

var sendEmail = function(eto, ecc, ebcc, efrom, esubject, etext_message, ehtml_message, callback) {
  // Running on AWS Lambda
  var aws         = require('aws-sdk');
  var ses = new aws.SES({apiVersion: '2010-12-01'});
  var to = eto;
  var cc = ecc;
  var bcc = ebcc;
  var from = efrom;
  var subject = esubject;
  var textMessage = etext_message;
  var htmlMessage = ehtml_message;
  var charSet = "UTF-8";
  var params = {
    Destination: {
      BccAddresses: bcc ? bcc : [],
      CcAddresses: cc ? cc : [],
      ToAddresses: to
    },
    Message: {
      Body: {},
      Subject: {
        Data: subject ? subject : "No subject",
        Charset: charSet
      }
    },
    Source: from,
    ReplyToAddresses: [from]
  };

  if (textMessage != null && textMessage.length > 0) {
    params["Message"]["Body"]["Text"] = {
      Data: textMessage,
      Charset: charSet
    }
  }
  if (htmlMessage != null && htmlMessage.length > 0) {
    params["Message"]["Body"]["Html"] = {
      Data: htmlMessage,
      Charset: charSet
    }
  }

  ses.sendEmail(params, function(err, data) {
    if (err) {
      console.log(err, err.stack); // an error occurred
    } else {
      console.log(data);           // successful response
      context.done();
    }
  });
}

var cloudedsendEmail = lambdawsC(sendEmail, ['fs', 'aws-sdk'], {
  name: 'sendEmail'
});

lambdaws.start();

cloudedsendEmail(['NAME@NAME'], 'NAME@NAME', 'MESSAGE SUBJECT', 'TEXT', '<b>TEXT</b>', function(data) {
  console.log("Email Sent ", data)
});

@ramonck Can you please confirm the Role you pass Lambdaws has full access to SQS?

Hi,

Yes it does, here's the policies list:
AmazonSQSFullAccess
AmazonSESFullAccess
AmazonDynamoDBFullAccess
AmazonEC2FullAccess
AmazonS3FullAccess
AWSElasticBeanstalkFullAccess
AWSLambdaFullAccess
lambda-web

@ramonck Can you raise the Upload Timeout doing so and see if the upload succeeds?

lambdaws.config({
  credentials: {
    accessKey: 'MYACCESSKEY',  // string, AWS AccessKeyId.
    secretKey: 'MYSECRETKEY',  // string, AWS AccessKeySecret.
  },
  role: 'arn:aws:iam::999999999999999:role/lambda_exec_role',  // string, AWS ARN. Must have full access to SQS.
  region: 'us-east-1',
  uploadTimeout: 30000
});

There are other issues with your function that we need to discuss (i.e. it won't run) but the first part is getting it to upload.

Hi,

The function runs currently with lambleg, I'm just trying to test the lambdaws to see if the generated code is cleaner.

I got the same results as before, not sure if this is correct for the library: --> the process didn't exit.

I get a generated Lambda like this default-4ac295c9444fccd435969f987a****** code size being 336.7 kB and I cannot edit inline the function.

Hi,
looks like your "upload timed out" issue disapeared. There are two issues with your function:

  1. With Lambdaws, you should not call context.done. You need to respond to the callback function instead.
  2. When I run the example code you pasted, I get the following error in CloudWatch:
{ [MultipleValidationErrors: There were 3 validation errors: * InvalidParameterType: Expected params.Destination.BccAddresses to be an Array * InvalidParameterType: Expected params.Destination.CcAddresses to be an Array * InvalidParameterType: Expected params.Message.Body.Text.Data to be a string] message: 'There were 3 validation errors:\n* InvalidParameterType: Expected params.Destination.BccAddresses to be an Array\n* InvalidParameterType: Expected params.Destination.CcAddresses to be an Array\n* InvalidParameterType: Expected params.Message.Body.Text.Data to be a string', code: 'MultipleValidationErrors',

FYI, tonight there will be a Pull Request from me adding support for function execution errors. You won't have to go on CloudWatch to see the exceptions, your callback function will always be called whatever the error.

We really want you to use Lambdaws so please tell us whatever you don't like or doesn't work for you about the library so we can assist.

Thanks

The --> means the function got launched on AWS Lambda successfully. The process not exiting is that we are waiting for the function to finish (or there's been an error). In the case of error, this will be fixed tonight like said above.

Hi Sylvain,

First, thanks for the feedback.

I see what you mean by the error, this is probably due to how the library is structured on the function call of the cloud function, this meaning in the function call I'm forced into inputting all the fields, that's why it's complaining about field types, it expects all the fields in the correct order.

I see it should be just like lambda which expects an object and if I set it in there or not it should be passed into the function.

Best Regards,

@ramonck You are welcome. Please close this issue if the problem is resolved and feel free to open a new issue if you have encounter a new problem.
Thanks