Author - StudySection Post Views - 259 views
Lambda

Call an AWS.Lambda function from another lambda function

If you have multiple Lambda functions that depend on each other, your current Lambda function may need the execution output of another Lambda function to process it.
In such cases, you should/have to call the dependent lambda function from the current lambda function.
Please check the example below. We have two lambda functions.

  1. process PDF contents – pdf_invoice
  2. save PDF contents in the database – save_invoice
  3. We are going to use nodejs to implement this scenario.

Function – pdf_invoice

Let’s write the code for pdf_invoice lambda function.
Pdf_invoice.js
lamda-01

Function – save_invoice

Let’s write the code for the lambda function save_invoice
We require the AWS SDK to call the lambda function (i.e aws-sdk).
If you are using AWS Lambda then no need aws-sdk, Otherwise, we need to install it.
Save_invoice.js
lamda-02

Syntax:

Invoke the target function by calling the invoke() method of the client object. Here’s an example:
lamda-03

In the above example, FunctionName should be the name or ARN (Amazon Resource Name) of the target function. InvocationType specifies whether the invocation is synchronous (RequestResponse) or asynchronous (Event). Payload is the input data to be passed to the target function, encoded as a JSON string.

In above code lambda.invoke(params).promise() will call the lambda function and return the response.
In above code response.Payload will provide the response returned by the lambda function.

If you have skills in PHP programming and you want to enhance your career in this field, a PHP certification from StudySection can help you reach your desired goals. Both beginner level and expert level PHP Certification Exams are offered by StudySection along with other programming certification exams.

Leave a Reply

Your email address will not be published. Required fields are marked *

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri