Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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.3k 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
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.2k users

Browse Categories

...