Search code examples
pythonamazon-web-servicesaws-lambda

Lambda calling Lambda - how to access the payload in the second?


I'm calling a Lambda from another Lambda asynchronously using:

payload = {"id":item['id']}
invoke_lambda = lambda_client.invoke(FunctionName="process",
                                     InvocationType="Event",
                                     Payload=json.dumps(payload)) # Use InvocationType="RequestResponse" for synchronous run

This is likely rather obvious, but I can't find the documentation for it - how do I access the payload in the second lambda defined as:

def process(event, context):
    (...)

Solution

  • On the second lambda, you just need to do id = context['id']. When it's an asynchronous call, event doesn't come with the body key.