I'm trying to work out two basic lambdas using Python2.7 runtime for SQS message processing.
One lambda reads from SQS invokes and passes data to another lambda via context. I can invoke the other lambda but the user context is empty in it. This is the code of SQS reader lambda I wrote:
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)
Nothing is working here and CloudWatch shows user context is empty:
('client_context', None)
I took reference from this as well: https://github.com/aws/aws-sdk-js/issues/1388 but still now working
Help!!!!