Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoking a lamnda from a lambda fails in SAM local #207

Closed
aleybovich opened this issue Nov 30, 2017 · 10 comments
Closed

Invoking a lamnda from a lambda fails in SAM local #207

aleybovich opened this issue Nov 30, 2017 · 10 comments

Comments

@aleybovich
Copy link

I have two lambdas runnignin SAM local, one of them (lambda1) is an api endpoint and it works fine. Now, I add another lambda (lambda2) and I want lambda1 to call it, so I add this code in lambda1:

const lambda = new aws.Lambda({ region: 'us-east-1' });
    lambda.invoke({
        FunctionName: 'lambda2',
        InvocationType: 'Event',
        LogType: 'None',
    }, (err, data) => {
        console.log(err); // ERR HAS AN ERROR
        cb(null, { statusCode: 200, body: data });
    });

And Lambda2 is this:

module.exports.handler = (event, context, cb) => {
    cb(null, true);
};

I get an error in the callback:

{"message":"connect ECONNREFUSED 192.168.65.1:8000","code":"NetworkingError","errno":"ECONNREFUSED","syscall":"connect","address":"192.168.65.1","port":8000,"region":"us-east-1","hostname":"docker.for.mac.localhost","retryable":true,"time":"2017-11-30T18:04:24.985Z"}

Any ideas?

@iph
Copy link

iph commented Dec 2, 2017

Today, I don't believe we support the exact api as Lambda itself. This sucks because of these types of oddities when you want a completely local experience.

Seems to be related to #12

I think this would be awesome to have, might start trying to chop away at that bit if no one else is working on it.

@MarkWilliams76
Copy link

Hi,

I need to call a Lambda from a Lambda too within SAM local (and then use SAM local to create my Lambdas in the console). Has this been implemented yet?

@sebastian-schlecht
Copy link

Any progress on this?

@MarkWilliams76
Copy link

I set up a Lambda to Lambda call on my AWS console and the steps I followed are below. This might be useful for setting up a corresponding call in SAM Local (as I would like to use the template file to deploy to AWS too).

  1. The calling and called Lambda had to be in the same region
  2. I had to create an IAM Role and attach the following policies, AWSLambdaExecute, AWSLambdaRole, and AWSLambdaBasicExecuteRole (I haven't verified if this last policy is required - see the Stackoverflow link I followed below). Then I assigned this as the execution role for the calling Lambda.
  3. The invocation type I used was RequestResponse. The example above used Event which didn't work for me.

https://stackoverflow.com/questions/35754766/nodejs-invoke-an-aws-lambda-function-from-within-another-lambda-function

@aleybovich
Copy link
Author

@MarkWilliams76 do both lambdas run in SAM local? The SO link you provided is about invoking a lambda from another lambda in AWS, not locally.

@MarkWilliams76
Copy link

@aleybovich No. The steps I'm talking about are via AWS Console. I posted as it's what I want to replicate locally in SAM local.

@sanathkr
Copy link
Contributor

sanathkr commented Jun 1, 2018

Closing this issue as a dupe of #12

@sanathkr sanathkr closed this as completed Jun 1, 2018
@leandroz
Copy link

@sanathkr I don't think is a duplicate, in #12 is talking about invoking the lambda function from the CLI, while here is talking about the invocation from the code itself.
I get the same ECONNREFUSED when trying to make a request to a lambda from a lambda, any ideas?

@lceni
Copy link

lceni commented Nov 29, 2018

Hello, any progress on this?

@markwaddle
Copy link

this might be superseded by #510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants