Complete the code to read records from a DynamoDB stream.
for record in event['Records']: print(record['[1]'])
The eventName field tells what kind of change happened (INSERT, MODIFY, REMOVE) in the stream record.
Complete the code to get the new image of the changed item from the stream record.
new_image = record['dynamodb']['[1]']
The NewImage contains the new state of the item after the change.
Fix the error in the code to check if the event is an INSERT.
if record['eventName'] == '[1]': print('New item inserted')
The event name for a new item added to the table is INSERT.
Fill both blanks to filter stream records for MODIFY events and get the old image.
if record['[1]'] == 'MODIFY': old_image = record['dynamodb']['[2]']
To check the event type, use eventName. For the previous state of the item, use OldImage.
Fill all three blanks to create a dictionary of item keys and their new values for INSERT events.
if record['[1]'] == 'INSERT': new_image = record['dynamodb']['[2]'] keys = {k: v['[3]'] for k, v in new_image.items()}
Check event type with eventName, get new data from NewImage, and extract string values with 'S' from DynamoDB attribute maps.