Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I have 2 Lambda functions - one that produces a quote and one that turns a quote into an order. I'd like the Order lambda function to call the Quote function to regenerate the quote, rather than just receive it from an untrusted client.

I've looked everywhere I can think of - but can't see how I'd go about chaining or calling the functions...surely this exists!

1 Answer

0 votes
by (44.4k points)

You can do this using the aws-sdk:

var aws = require('aws-sdk');

var lambda = new aws.Lambda({

  region: 'us-west-2' //change to your region

});

lambda.invoke({

  FunctionName: 'name_of_your_lambda_function',

  Payload: JSON.stringify(event, null, 2) // pass params

}, function(error, data) {

  if (error) {

    context.done('error', error);

  }

  if(data.Payload){

   context.succeed(data.Payload)

  }

});
 

For more information, check this out:

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html 

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories

...