0
0
DynamoDBquery~20 mins

Lambda trigger on stream events in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Stream Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this Lambda event record processing?

Given a DynamoDB stream event with the following record snippet, what will the Lambda function log for the NewImage attribute?

{
  "Records": [
    {
      "eventID": "1",
      "eventName": "INSERT",
      "dynamodb": {
        "NewImage": {
          "UserId": {"S": "123"},
          "Score": {"N": "42"}
        }
      }
    }
  ]
}

Assume the Lambda code logs event.Records[0].dynamodb.NewImage.UserId.S and event.Records[0].dynamodb.NewImage.Score.N.

A"UserId: 123, Score: 42"
B"UserId: S, Score: N"
C"UserId: UserId, Score: Score"
D"UserId: null, Score: null"
Attempts:
2 left
💡 Hint

Remember DynamoDB stream records store attribute values as objects with type keys like S for string and N for number.

🧠 Conceptual
intermediate
1:30remaining
Which event types trigger a Lambda from DynamoDB Streams?

Which of the following DynamoDB stream event types can trigger a Lambda function?

AINSERT, MODIFY, REMOVE
BCREATE, UPDATE, DELETE
CADD, REPLACE, DELETE
DPUT, PATCH, DELETE
Attempts:
2 left
💡 Hint

Think about the standard DynamoDB stream event names.

📝 Syntax
advanced
1:30remaining
Identify the syntax error in this Lambda handler for DynamoDB stream

Which option contains a syntax error in this Lambda function snippet that processes DynamoDB stream events?

exports.handler = async (event) => {
  for (const record of event.Records) {
    console.log('Event ID:', record.eventID);
    console.log('Event Name:', record.eventName);
    console.log('New Image:', record.dynamodb.NewImage);
  }
}
AMissing semicolon after console.log statements
BArrow function missing parentheses around event parameter
CIncorrect use of >= instead of => in arrow function
DNo syntax error; code is valid
Attempts:
2 left
💡 Hint

Check the arrow function syntax and console.log usage.

optimization
advanced
2:00remaining
Best practice to handle batch size in Lambda triggered by DynamoDB Streams

You want to optimize your Lambda function triggered by DynamoDB Streams to process records efficiently without timing out. Which approach is best?

ASet batch size to 1 to process each record individually
BSet a moderate batch size (e.g., 100) and process records asynchronously with error handling
CSet batch size to 1000 and process all records synchronously in one invocation
DDisable batch processing and poll the stream manually
Attempts:
2 left
💡 Hint

Consider balancing throughput and Lambda execution time.

🔧 Debug
expert
2:30remaining
Why does this Lambda triggered by DynamoDB Streams fail to process some records?

Consider this Lambda function snippet triggered by DynamoDB Streams:

exports.handler = async (event) => {
  event.Records.forEach(async (record) => {
    await processRecord(record);
  });
};

Why might some records not be processed before the Lambda finishes?

AEvent object is missing Records array
BLambda times out before processing starts
CUsing forEach with async functions does not wait for promises to resolve
DprocessRecord function is not awaited properly inside forEach
Attempts:
2 left
💡 Hint

Think about how async functions behave inside forEach loops.