0
0
DynamoDBquery~10 mins

Stream vs polling comparison in DynamoDB - Interactive Practice

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

Complete the code to enable DynamoDB Streams on a table.

DynamoDB
aws dynamodb update-table --table-name MyTable --stream-specification StreamEnabled=[1],StreamViewType=NEW_IMAGE
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
Cenabled
Don
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'enabled' or 'on' instead of true.
Using uppercase True which is invalid in CLI.
2fill in blank
medium

Complete the code to poll DynamoDB for new records using the AWS SDK.

DynamoDB
const params = { StreamArn: 'MyStreamArn', [1]: 'LATEST' };
Drag options to blanks, or click blank then click option'
AShardIteratorType
BStreamArn
CStreamViewType
DStreamLabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using StreamViewType which defines what data is captured.
Using StreamArn which is the stream's identifier.
3fill in blank
hard

Fix the error in this polling code snippet to correctly retrieve records from DynamoDB Streams.

DynamoDB
const records = await dynamodbstreams.getRecords({ ShardIterator: [1] }).promise();
Drag options to blanks, or click blank then click option'
AshardIterator
BShardIterator
Csharditerator
DSharditerator
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or incorrect casing causes runtime errors.
Misspelling the parameter name.
4fill in blank
hard

Fill both blanks to create a DynamoDB Stream event handler that processes new records.

DynamoDB
exports.handler = async (event) => {
  for (const record of event.[1]) {
    if (record.eventName === '[2]') {
      console.log('New record:', record.dynamodb.NewImage);
    }
  }
};
Drag options to blanks, or click blank then click option'
ARecords
BEvents
CINSERT
DMODIFY
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Events' instead of 'Records'.
Checking for 'MODIFY' instead of 'INSERT' when looking for new records.
5fill in blank
hard

Fill all three blanks to create a polling loop that fetches and processes DynamoDB Stream records.

DynamoDB
let shardIterator = await dynamodbstreams.getShardIterator({
  StreamArn: streamArn,
  ShardId: shardId,
  ShardIteratorType: '[1]'
}).promise().then(data => data.[2]);

while (shardIterator) {
  const data = await dynamodbstreams.getRecords({ ShardIterator: shardIterator }).promise();
  data.[3].forEach(record => {
    console.log('Record:', record);
  });
  shardIterator = data.NextShardIterator;
  await new Promise(resolve => setTimeout(resolve, 1000));
}
Drag options to blanks, or click blank then click option'
ATRIM_HORIZON
BShardIterator
CRecords
DLATEST
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'TRIM_HORIZON' instead of 'LATEST' when wanting newest records.
Accessing wrong property name for iterator or records.
Not waiting between polls causing throttling.