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}
Let the name of this function be – “ChildFunction” and select Python 3.8 as the runtime. Select the option to Create a new role with basic lambda permissions and click on Create Function. A new lambda function will be created where you can write your code and test it.
From the deprecation date of July 15, 2021, Lambda will no longer apply security patches and other updates to the Python 2.7 runtime used by Lambda functions. In addition, functions using Python 2.7 will no longer be eligible for technical support.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With