0
0
DynamoDBquery~10 mins

Stream processing patterns in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to read records from a DynamoDB stream.

DynamoDB
for record in event['Records']:
    print(record['[1]'])
Drag options to blanks, or click blank then click option'
AeventName
BstreamViewType
CawsRegion
Ddynamodb
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'dynamodb' instead of 'eventName' will print the whole DynamoDB data, not the event type.
Using 'streamViewType' or 'awsRegion' does not give the event type.
2fill in blank
medium

Complete the code to get the new image of the changed item from the stream record.

DynamoDB
new_image = record['dynamodb']['[1]']
Drag options to blanks, or click blank then click option'
AOldImage
BKeys
CNewImage
DSequenceNumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'OldImage' will give the previous state, not the new one.
Using 'Keys' or 'SequenceNumber' does not provide the item data.
3fill in blank
hard

Fix the error in the code to check if the event is an INSERT.

DynamoDB
if record['eventName'] == '[1]':
    print('New item inserted')
Drag options to blanks, or click blank then click option'
AREMOVE
BINSERT
CUPDATE
DMODIFY
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'UPDATE' or 'MODIFY' instead of 'INSERT' will not detect new items.
Using 'REMOVE' checks for deletions, not insertions.
4fill in blank
hard

Fill both blanks to filter stream records for MODIFY events and get the old image.

DynamoDB
if record['[1]'] == 'MODIFY':
    old_image = record['dynamodb']['[2]']
Drag options to blanks, or click blank then click option'
AeventName
BNewImage
COldImage
DKeys
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'NewImage' instead of 'OldImage' will give the updated data, not the old.
Checking 'Keys' instead of 'eventName' will not filter events.
5fill in blank
hard

Fill all three blanks to create a dictionary of item keys and their new values for INSERT events.

DynamoDB
if record['[1]'] == 'INSERT':
    new_image = record['dynamodb']['[2]']
    keys = {k: v['[3]'] for k, v in new_image.items()}
Drag options to blanks, or click blank then click option'
AeventName
BNewImage
CS
DOldImage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'OldImage' instead of 'NewImage' will get old data.
Using 'N' or other keys instead of 'S' will not extract string values correctly.