1

I want to invoke second Lambda function from first lambda function using Python. To invoke I'm using below code snippet: lambda_client = boto3.client('lambda')

def lambda_handler(event, context):
    invoke_response = lambda_client.invoke(FunctionName="teststack",InvocationType='RequestResponse')

In that I want to pass two additional parameter, for example: Name and age to the second lambda function, can someone help how I can pass additional parameter to another lambda function and how to receive it in second lambda function.

Thanks for your help in advance!

Mark B
  • 183,023
  • 24
  • 297
  • 295
learn java
  • 231
  • 3
  • 14

1 Answers1

3

You have two options. From the official documentation:

ClientContext (string) -- Using the ClientContext you can pass client-specific information to the Lambda function you are invoking. You can then process the client information in your Lambda function as you choose through the context variable. For an example of a ClientContext JSON, see PutEvents in the Amazon Mobile Analytics API Reference and User Guide .

The ClientContext JSON must be base64-encoded.

Payload (bytes or seekable file-like object) -- JSON that you want to provide to your Lambda function as input.

In the Lambda function, the Payload is available via the event parameter. The ClientContext is available via the context parameter.

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • Thanks Mark! I'm not able to call one lambda function to another lambda function. I'm not getting any error but its keep on loading and its timing out after 5 minutes. What could be the reason, any idea? – learn java Dec 12 '16 at 22:43
  • You probably enabled VPC access on your Lambda function, without adding a NAT gateway to your VPC, so the Lambda function no longer has access to the AWS API. Either remove the Lambda function from the VPC, or add a NAT gateway to your VPC. See this: http://stackoverflow.com/questions/38188532/why-aws-lambda-within-vpc-can-not-send-message-to-sns – Mark B Dec 13 '16 at 00:56