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?
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.
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?
Any progress on this?
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).
@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.
@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.
Closing this issue as a dupe of #12
@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?
Hello, any progress on this?
this might be superseded by #510
Most helpful comment
@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?