I have create 2 simple Lambda function using a Python 2.7 runtime and the trigger is SQS.
The first Lambda function reads the messages from the SQS queue which is the actually the trigger of the function. Now, I am able to invoke the second lambda function but the user context part is empty. The code for SQS reader is below:
import boto3
import base64
import json
import logging
messageDict = {'queue_url': 'queue_url',
'receipt_handle': 'receipt_handle',
'body': 'messageBody'}
ctx = {
'custom': messageDict,
'client': 'SQS_READER_LAMBDA',
'env': {'test': 'test'},
}
payload = json.dumps(ctx)
payloadBase64 = base64.b64encode(payload)
client = boto3.client('lambda')
client.invoke(
FunctionName='LambdaWorker',
InvocationType='Event',
LogType='None',
ClientContext=payloadBase64,
Payload=payload
)
And this is how I'm trying to inspect and print the contents of context variable inside invoked lambda, so I could check logs in CloudWatch:
memberList = inspect.getmembers(context)
for a in memberList:
logging.error(a)
It isn't working and CloudWatch shows the below output that there is no context:
('client_context', None)
I took reference from this as well: https://github.com/aws/aws-sdk-js/issues/1388 but still now working