0

I have multiple Lambda functions. I am calling another Lambda function from the first Lambda function using Lambda invoke in python. I have an object instance of the class which has has the dictionary data. I also want to pass the object instance to the other lambda functions with the json object. How can I do it?

objReferenceData = ReferenceData()
objReferenceData_dict = objReferenceData.__dict__
"This objReferenceData_dict contains all the data which have dictonary object." 

## First lambda
inputForInvoker = responsejson
logger.info(inputForInvoker)
response = client.invoke(
            FunctionName = 'arn:aws:firstfun',
            InvocationType = 'RequestResponse',
            Payload = json.dumps(inputForInvoker)
                )
responsejson = json.load(response['Payload'])
return responsejson
            else:
                pass
            
## second lambda
inputForInvoker = responsejson
response = client.invoke(
            FunctionName = 'arn:aws:secondfun',
            InvocationType = 'RequestResponse',
            Payload = json.dumps(inputForInvoker)
                )
responsejson = json.load(response['Payload'])
else:
    pass

I want to pass the objReferenceData_dict with the responsejson. I tried to send that, adding this objReferenceData_dict to the responsejson but the data is too large. The lambda handler only has a limit of 6mb.

1 Answer 1

1

You seem to understand the api for invoking another lambda synchronously, so it seems your only issue is the 6MB limit. This is a hard limit according to the documentation.

Therefore, you must choose another method for data transfer. There are, of course, many options. Two that come to mind are writing the data as an object to s3 with put_object, or sending the message to an sqs queue since you can Now Send Payloads up to 2GB with Amazon SQS.

For the former, you would invoke the second lambda with the key of the s3 object. For the latter, you would trigger the second lambda via the queue, and then handle the response with a different workflow.

In any case, if you need to invoke with more that 6MB, you cannot pass the payload directly.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Thank you so much for your response. Iam bit worried about the performance and speed when trying to call the data from s3 to lambda.
I’m not sure what your needs are but traveling between lambdas would use the same network so it shouldn’t be too bad. If you have tight latency concerns you may want to join to one lambda or consider eke or ecs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.