I've set a DynamoDB stream to trigger a simple Lambda function, which works to trigger the function but returns an empty event object. I'm expecting the usual response with Keys, Oldimage, Newimage etc...
The event is passed correctly when I test the function manually in the console as well as when I trigger it with API Gateway. My Execution role has admin access. I even replicated the aws stream/lambda tutorial with the same issue. This should be really simple to do and it's driving me crazy!
My function couldn't be any simpler:
def get_event(event, context):
print(event)
return {
'statusCode': 200,
'body': event
}
And here is my CloudWatch Log with the empty event:
"StatusCode": 200,
"LogResult": START RequestId: 48ec33f4-8707-4d16-9f53-4c7fcf7413d1 Version: $LATEST
{}
END RequestId: 48ec33f4-8707-4d16-9f53-4c7fcf7413d1
REPORT RequestId: 48ec33f4-8707-4d16-9f53-4c7fcf7413d1 Duration: 7.74 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 71 MB
In case it's useful, my Event source mapping for my function
{
"EventSourceMappings": [
{
"UUID": "ce6d850*********************",
"BatchSize": 100,
"EventSourceArn": "arn:aws:dynamodb:us-east- 1:**********:table/EventsDatabase/stream/2019-06-24T14:02:23.578",
"FunctionArn": "arn:aws:lambda:us-east-1:***********:function:email_sender",
"LastModified": 1561872060.0,
"LastProcessingResult": "OK",
"State": "Enabled",
"StateTransitionReason": "User action"
}
]
}
event
doesn't seam like the Function was invoked from the DynamoDB Stream. It looks more like you called your function manually expecting it to read from stream. Try to change/add some items in the DynamoDB and see if your function is invoked (and with what payload). Otherwise could you please show the configuration of the DynamoDB Stream itself. – Nikolay Grischenkoyour_file_name.get_event
? 2) What is ViewType configured for your stream? Check these settings from the DynamoDB side. Probably you have OLD_IMAGE and for creating new items it doesn't include anything (only for modifications). 3) Also try for testing to change the batch_size of stream from 100 to 1. Although if you have your Lambda invoked - this means you reach this batch size somehow. – Nikolay Grischenko