0
0
AWScloud~20 mins

Lambda with DynamoDB Streams in AWS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Lambda DynamoDB Streams Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
Lambda Trigger Behavior on DynamoDB Stream Batch

You have a Lambda function triggered by a DynamoDB stream with batch size set to 5. The stream receives 7 new records at once. How many times will the Lambda function be invoked?

AThe Lambda function will be invoked 2 times: once with 5 records and once with 2 records.
BThe Lambda function will be invoked 1 time with 7 records in the batch.
CThe Lambda function will be invoked 7 times, once per record.
DThe Lambda function will not be invoked automatically.
Attempts:
2 left
💡 Hint

Think about how batch size controls the maximum number of records per invocation.

Architecture
intermediate
2:00remaining
Ensuring Exactly-Once Processing with Lambda and DynamoDB Streams

You want to process DynamoDB stream records with a Lambda function ensuring each record is processed exactly once, even if retries happen. Which architectural choice helps achieve this?

AUse Lambda with DynamoDB Streams and implement idempotent processing in the Lambda function.
BUse Lambda with DynamoDB Streams and set batch size to 1 to avoid retries.
CUse Lambda with DynamoDB Streams and rely on Lambda's automatic retry without additional logic.
DUse Lambda with DynamoDB Streams and disable the stream to prevent duplicate processing.
Attempts:
2 left
💡 Hint

Consider how retries can cause duplicate processing and how to handle it.

Configuration
advanced
2:00remaining
Configuring Lambda Event Source Mapping for DynamoDB Streams

Given this AWS CLI command to create an event source mapping for a Lambda function triggered by a DynamoDB stream, what is the effect of the --starting-position TRIM_HORIZON parameter?

aws lambda create-event-source-mapping \
  --function-name MyLambdaFunction \
  --event-source-arn arn:aws:dynamodb:us-east-1:123456789012:table/MyTable/stream/2023-01-01T00:00:00.000 \
  --starting-position TRIM_HORIZON \
  --batch-size 10
AThe Lambda function will start processing only new records added after the mapping is created.
BThe Lambda function will ignore the stream and run on a schedule.
CThe Lambda function will process records in reverse order, starting from the newest.
DThe Lambda function will start processing from the oldest available record in the stream.
Attempts:
2 left
💡 Hint

Think about what 'TRIM_HORIZON' means in stream processing.

security
advanced
2:00remaining
IAM Permissions for Lambda to Read DynamoDB Streams

Which IAM permission is required for a Lambda function to read records from a DynamoDB stream?

Adynamodb:DeleteItem
Bdynamodb:PutItem
Cdynamodb:GetRecords
Dlambda:InvokeFunction
Attempts:
2 left
💡 Hint

Consider what action allows reading stream records.

Best Practice
expert
2:00remaining
Handling Partial Failures in Lambda Processing of DynamoDB Streams

Your Lambda function processes batches of DynamoDB stream records. If processing one record in the batch fails, what is the best practice to avoid losing other successfully processed records?

ASet batch size to 1 to avoid batch failures.
BProcess records individually inside Lambda and handle failures per record, using partial batch response feature.
CLet the entire batch fail so Lambda retries all records, including successful ones.
DDisable retries in Lambda to prevent duplicate processing.
Attempts:
2 left
💡 Hint

Think about how to handle failures without reprocessing successful records.