0
0
AWScloud~10 mins

Lambda with DynamoDB Streams in AWS - Interactive Code Practice

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

Complete the code to specify the event source for the Lambda function.

AWS
EventSourceArn: [1]
Drag options to blanks, or click blank then click option'
A"arn:aws:dynamodb:us-east-1:123456789012:table/MyTable/stream/2023-01-01T00:00:00.000"
B"arn:aws:s3:::my-bucket"
C"arn:aws:lambda:us-east-1:123456789012:function:MyFunction"
D"arn:aws:sqs:us-east-1:123456789012:MyQueue"
Attempts:
3 left
💡 Hint
Common Mistakes
Using an S3 bucket ARN instead of a DynamoDB stream ARN.
2fill in blank
medium

Complete the code to set the batch size for processing records from the stream.

AWS
BatchSize: [1]
Drag options to blanks, or click blank then click option'
A1
B1000
C10
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Setting batch size too high causing timeouts or too low causing inefficiency.
3fill in blank
hard

Fix the error in the Lambda function handler to correctly process DynamoDB stream records.

AWS
def lambda_handler(event, context):
    for record in [1]:
        print(record['dynamodb']['Keys'])
Drag options to blanks, or click blank then click option'
Acontext['Records']
Bevent['records']
Cevent['Records']
Dcontext['records']
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'records' which does not exist in the event object.
4fill in blank
hard

Fill both blanks to filter only INSERT events and extract the new image from the record.

AWS
for record in event['Records']:
    if record['eventName'] == [1]:
        new_image = record['dynamodb'][[2]]
Drag options to blanks, or click blank then click option'
A"INSERT"
B"REMOVE"
C"NewImage"
D"OldImage"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'REMOVE' eventName or accessing 'OldImage' for inserts.
5fill in blank
hard

Fill all three blanks to configure the Lambda event source mapping with batch size, starting position, and enable the mapping.

AWS
response = lambda_client.create_event_source_mapping(
    EventSourceArn=[1],
    FunctionName=[2],
    BatchSize=[3],
    StartingPosition='TRIM_HORIZON',
    Enabled=True
)
Drag options to blanks, or click blank then click option'
A"arn:aws:dynamodb:us-west-2:123456789012:table/Orders/stream/2024-01-01T00:00:00.000"
B"MyLambdaFunction"
C100
D"MyDynamoDBTable"
Attempts:
3 left
💡 Hint
Common Mistakes
Using table name instead of stream ARN for EventSourceArn.
Using incorrect function name or batch size.