Reputation: 469
I have a AWS Lambda function that passes a set of parameters to another function; after some processing, this second function should return a value, but for some reason the first function does not receive that value.
This is the caller function:
import boto3
lam = boto3.client('lambda')
def lambda_handler(event, context):
payload={}
payload['key1'] = 'Test Value'
response=lam.invoke(FunctionName='callee', InvocationType='RequestResponse', Payload=json.dumps(payload))
print(response)
This is callee function:
def lambda_handler(event, context):
print('value1=' + event['key1'])
return event['key1']
The callee function prints the value as expected, but caller function does not receive the return from callee.
How can I fix this? Thank you.
Upvotes: 1
Views: 2041
Reputation: 270254
The response
object comes back as:
{
'ResponseMetadata': {...},
'StatusCode': 200,
'ExecutedVersion': '$LATEST',
'Payload': <botocore.response.StreamingBody object at 0x7f34aea2d240>
}
You can then extract the return value via:
print(response['Payload'].read())
Upvotes: 2