Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 01 2019 16:35
    praveenvelampudi7 commented #49
  • May 29 2018 19:21
    contractorwolf commented #49
  • May 10 2018 02:55
    deoresheetal commented #49
  • Sep 27 2017 13:25
    contractorwolf unassigned #49
  • Sep 27 2017 13:25
    contractorwolf commented #49
  • May 12 2017 15:22

    EFF on master

    Update README.md (compare)

  • May 12 2017 15:21
    EFF closed #70
  • May 12 2017 15:21
    EFF commented #70
  • May 11 2017 00:04
    Echelonsecretintelligenceofficer commented #70
  • Feb 13 2016 03:45
    vboctor opened #70
  • Jan 13 2016 18:31

    EFF on master

    Update README.md (compare)

  • Dec 11 2015 22:00
    adelevie opened #69
  • Oct 23 2015 15:55
    EFF commented #68
  • Oct 16 2015 18:31
    jakelodwick opened #68
  • Oct 06 2015 15:52
    oortlieb commented #67
  • Oct 06 2015 15:47
    slvnperron commented #67
  • Oct 06 2015 15:34
    oortlieb opened #67
  • Oct 01 2015 04:45
    chrxn commented #66
  • Sep 29 2015 17:00

    slvnperron on master

    Added 'logs:*' as a required pe… Merge pull request #66 from chr… (compare)

  • Sep 29 2015 17:00
    slvnperron closed #66
Raphaël Antonmattei
@rantonmattei
so, I was about to submit a PR for that
however I ran into another issue with this line
event.args.push(doneCallback);
https://github.com/mentum/lambdaws/blob/master/lib/LambdaHelper.js#L46
because in my case, the args property is not defined
Here is the event object I get back from the invocation
[ { eventVersion: '2.0', eventSource: 'aws:s3', awsRegion: 'us-east-1', eventTime: '2015-03-18T15:40:07.417Z', eventName: 'ObjectCreated:Put', userIdentity: [Object], requestParameters: [Object], responseElements: [Object], s3: [Object] } ] }
So, that line triggers an error
Failure while running task: TypeError: Cannot call method 'push' of undefined at __lambda__ (/var/task/index.js:13:20)
Raphaël Antonmattei
@rantonmattei
So, it seems there are differences between your examples (calling lambda from a local process) and what I am doing (calling from an S3 events)
In your example, you do need args
var minus = function(a, b, callback) { /*...*/ };
With S3 events you need the entire event obj and the context
var myFunc = function(event, context) { /*...*/ };
So, if I add my change, it's going to break the scenario in your example
Raphaël Antonmattei
@rantonmattei
so, here is what I suggest:
function __lambda__ (event, context) {
    var utils               = require('./_utils'),
        callbackHandler     = require('./_callbackHandler'),
        externalsHandler    = require('./_externalsHandler');

    var doneCallback = callbackHandler.getCallback(event, context);

    if (event.args) {
        event.args.push(doneCallback);
    }

    var externals = /*externals*/null; // The external libraries to install, injected below
    var func = /*user function*/null; // The user function or module to run, injected below

    var runUserFunction = function() {
        try {
            if (event.args) {
                func.apply(this, event.args);
            } else {
                func.apply(this, [event, context]);
            }
        } catch(error) {
            doneCallback(utils.objectifyError(error));
        }
    };

    try { externalsHandler.installExternals(externals, runUserFunction) }
    catch(error) { doneCallback(utils.objectifyError(error)) }
}
Raphaël Antonmattei
@rantonmattei
I've a PR out: mentum/lambdaws#63
Sylvain Perron
@slvnperron
@rantonmattei You are right about the events thing. Thanks a lot for the contribution. I’ll have a look later today!
Raphaël Antonmattei
@rantonmattei
@slvnperron I read your comments and made the requested changes.
Sylvain Perron
@slvnperron
@rantonmattei Awesome! PR merged
Gustav Svalander
@gurre
What AMI roles does lambdaws require more specifically? Needs to be added to the docs.
Sylvain Perron
@slvnperron
@gurre R/W SQS, Lambda full access
zulutune
@zulutune

Hey guys,
When I start a new process with require('child_process').spawn I always get "Spawn EACCES".
And when I use require('child_process').execFile, I get "Process exited before completing request".
According to the lambda docs, lambda supports creating processes, and have seen lots of examples doing that. I can't figure out what I am doing wrong. Have a stripped down, simple version which doesn't work either:

var path = require('path'),
      childProcess = require('child_process')
      , fs = require('fs');

exports.handler = function(event, context) {
  console.log('starting handler', event);

  var nodePath = path.join(__dirname, 'node');
  var nodeArgs = [path.join(__dirname, 'hello.js')];

  console.log('calling node: ', nodePath, nodeArgs);

  try {
    var proc = childProcess.spawn(nodePath, nodeArgs);

    proc.stdout.on('data', function (data) {
      console.log(data.toString('utf8'));
    });

    proc.stderr.on('data', function (data) {
      console.log('error  ---:> ' + data);
    });

    proc.on('exit', function (code) {
      console.log('child process exited with code ' + code);
      context.done();
    });

  } catch (e) {
    console.log(e);
    context.done(e, null);
  }


};

Anyone ideas?

I'm using node just as an example here, and it also doesn't work with other binaries.
The file is an executable: "-rwxr-xr-x@ 1 zulutune staff 20231104 Mar 24 03:08 node"
Sylvain Perron
@slvnperron
Hi @zulutune , thanks for your interest in Lambdaws.
Have you had a look into how we invoke external processes with lambdaws?
This works well for us
You may also have a look at Lambdash
Austen
@ac360
Anyone around?
EFF
@EFF
@ac360 sorry to be slow on the keyboard mate got some news ?
or questions ?
Austen
@ac360
@EFF Has anyone been able to connect to an external DB like MongoDB in a Lambda instance using Lambdaws? I'm trying to fire lambdaws with the 'mongodb' dependency and not having much luck.
EFF
@EFF
how do you specify your dependency ?
What do you mean by not having much luck ? Do you have any errors logs in your AWS cloudwatch console ?
Jacques-Olivier D. Bernier
@jackdbernier
@ac360 Just to be sure. Are you creating the db connection inside the function running on aws lambda?
Austen
@ac360
@EFF sorry I keep missing you
@jackdbernier sorry to miss you too!
I've put aside the mongoDB issue since I built an app that is using DynamoDB
It's something I've been wanting to work with and since Lambda has DynamoDB support out-of-the-box, I thought I'd build a simple app that uses it
However, I do have one new question
On the start of my node applciation, I'd like to upload the Lambda functions, in case any have changed
I have a directory entitled 'lambda' in my application
I'm wondering if this will work in my main server.js file in node
    /**
    * Lambda Set-Up
    * - Upload all Lambda functions on server start so they are ready to be called
    */
     var λ = require('lambdaws').create;
     fs.readdirSync(path).forEach(function(file) {
          var lambda_function_path = __dirname + '/app/lambda/' + file;
          λ(require(lambda_function_path));
     });
Austen
@ac360
And is this a best practice?
Austen
@ac360
I figure it's just better to upload all functions at application start, rather than when they are actually called
Austen
@ac360
Hmm, running that throws the following error:
   node_modules/lambdaws/lib/zipper.js:66
                var callbackHandler = !!configs.ignoreResponse ? '_emptyCallbackHandle 
   TypeError: Cannot read property 'ignoreResponse' of undefined
Jacques-Olivier D. Bernier
@jackdbernier
You are missing arguments when calling create. The signature is something like create(handle, deps, config)
It seems like a bug that config does not have a default value since deps is defaulting to []
Though for now if you call it like that λ(require(lambda_function_path), [], {}); is should work.
Thanks for reporting.
Austen
@ac360
@jackdbernier are you around?
Anyone around?