I have a lambda function that needs to call another lambda and pass the same input parameters (event dictionary) However, my invocation fails. My invocation for 1st lambda is an s3 event
lambda_s3.invoke(
FunctionName='Function',
InvocationType='Event',
Payload=json.dumps(event)
)
I assume that Payload doesn't really work. How can I encode the payload so it's readable by the other lambda
json of the event that I try to pass:
{
'Records':[
{
'eventVersion':'2.0',
'eventSource':'aws:s3',
'awsRegion':'us-east-1',
'eventTime':'1970-01-01T00:00:00.000Z',
'eventName':'ObjectCreated:Put',
'userIdentity':{
'principalId':'AIDAJDPLRKLG7UEXAMPLE'
},
'requestParameters':{
'sourceIPAddress':'127.0.0.1'
},
'responseElements':{
'x-amz-request-id':'C3D13FE58DE4C810',
'x-amz-id-2':'FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD'
},
's3':{
's3SchemaVersion':'1.0',
'configurationId':'testConfigRule',
'bucket':{
'name':'my-faces-data',
'ownerIdentity':{
'principalId':'A3NL1KOZZKExample'
},
'arn':'arn:aws:s3:::my-faces-data'
},
'object':{
'key':'images/banana.jpg',
'size':1024,
'eTag':'d41d8cd98f00b204e9800998ecf8427e',
'versionId':'096fKKXTRTtl3on89fVO.nfljtsv6qko'
}
}
}
]}
You need to encode the payload. Your invocation should look like this:
lambda_s3.invoke(
FunctionName='Function',
InvocationType='RequestResponse',
Payload=json.dumps(event).encode()
)
Python boto3 explanation can be found here.
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