Complete the code to specify the event source ARN in the DynamoDB Streams trigger.
event_source_arn = "[1]"
The event source ARN for a DynamoDB Streams trigger must point to the stream ARN of the DynamoDB table.
Complete the code to specify the batch size for processing DynamoDB stream records.
batch_size = [1]The batch size for DynamoDB Streams processing is typically set to 10 to balance throughput and latency.
Fix the error in the DynamoDB stream event handler code to correctly process the event records.
def lambda_handler(event, context): for record in event['[1]']: print(record['eventName'])
The DynamoDB stream event object contains a key 'Records' (capital R) which holds the list of event records.
Fill both blanks to create a DynamoDB stream event filter that only processes INSERT events.
event_filter = {
'eventName': ['[1]'],
'eventSource': ['[2]']
}To filter for INSERT events, use 'INSERT' for eventName and 'aws:dynamodb' for eventSource.
Fill all three blanks to define a DynamoDB stream event handler that logs the new image keys for INSERT events.
def lambda_handler(event, context): for record in event['[1]']: if record['eventName'] == '[2]': new_image = record['dynamodb']['[3]'] print(new_image)
The event records are under 'Records', the event name for inserts is 'INSERT', and the new image data is under 'NewImage'.