Call AWS lambda function from an existing lambda function on Python 2.7
24,371
The response data you're looking for is there, it's just inside the Payload
as a StreamingBody object.
According to the Boto docs, you can read the object using the read
method:
invoke_response['Payload'].read()
Author by
shiv455
Updated on October 09, 2020Comments
-
shiv455 over 3 years
I'm trying to call another lambda function from an existing lambda fucntion as below (python 2.7)
from __future__ import print_function import boto3 import json lambda_client = boto3.client('lambda') def lambda_handler(event, context): invoke_response = lambda_client.invoke(FunctionName="teststack", InvocationType='RequestResponse' ) print(invoke_response) return str(invoke_response)
I'm gettting the below response instead of an actual result. When I run teststack lambda invidually it works fine, but getting below response instead of "test" returned by the
teststack
Lambda function.{u'Payload': <botocore.response.StreamingBody object at ****>, 'ResponseMetadata': {'HTTPStatusCode': 200, 'RequestId': '******', 'HTTPHeaders': {'x-amzn-requestid': '******', 'content-length': '155', 'x-amzn-remapped-content-length': '0', 'connection': 'keep-alive', 'date': 'Sun, 17 Jul 2016 21:02:01 GMT', 'content-type': 'application/json'}}, u'StatusCode': 200}