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):
(...)
To invoke a lambda function synchronously, use the invoke command, passing it the function name, the payload and the output filename as parameters. Copied! If you're on Windows , escape the double quotes of the --payload parameter, e.g. '{\"name\": \"John Smith\"}' .
In order to allow the ParentFunction to call the ChildFunction, we need to provide the ParentFunction with specific rights to call another lambda function. This can be done by adding specific policies to a role and then assign that role to the lambda function.
Async invocation means that the lambda that invokes the other lambda does not wait for the second lambda to finish and immediately returns. There are 2 lambdas. We will call them lambda-one and lambda-two. Lambda-one is invoked using APIGateway, and then lambda-one invokes the lambda-two asynchronously.
Your payload should be in the body
of the event
dict. Try json.loads(event['body']).get('id')
.
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