Calling Lambda Function from another Lambda Function synchronously - Node.js

AWS Lambda functions are very useful when you work with Alexa or SageMaker or for any serverless applications.
But if you have multiple Lambdas & wanted to call one from another, how to do it?
Lets find out.

AWS sdk provides a way to invoke Lambda, so we first need to import AWS sdk.


Here region is the region where the lambda to call resides.

Now lets add a function to call our second lambda


Here Function name is the name of function to call, InvocationType is RequestResponse for synchronous call and Payload is the data which we need to send.

We now have sdk & function ready, lets call the lambda now,


This will successfully return the result.

One important point is, the Role which the calling Lambda function use, must have InvokeAsync & invokeFunction rights. Go to IAM dashboard & add these Lambda actions.



Hope this helps.

Happy Coding,
Parshuram 

Comments

Popular posts from this blog

6000 KM Road Trip

Export MS Access report to Excel..Font Problem

Testing AWS Rekognition from POSTMAN