0
0
DynamoDBquery~10 mins

Lambda function with 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 import the AWS SDK for DynamoDB in a Lambda function.

DynamoDB
const AWS = require('[1]');
Drag options to blanks, or click blank then click option'
Aaws-sdk
Baws-sdk-client
Cdynamodb-sdk
Dlambda-sdk
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect package names like 'dynamodb-sdk' or 'lambda-sdk'.
Forgetting to import the AWS SDK before using DynamoDB.
2fill in blank
medium

Complete the code to create a DynamoDB DocumentClient instance in the Lambda function.

DynamoDB
const docClient = new AWS.[1]();
Drag options to blanks, or click blank then click option'
ADynamoDBClient
BDocumentClient
CDynamoDB
DDynamoClient
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'DynamoDBClient' which is part of the newer AWS SDK v3, not v2.
Using 'DynamoDB' which is the low-level client, not the DocumentClient.
3fill in blank
hard

Fix the error in the code to put an item into the DynamoDB table named 'Users'.

DynamoDB
const params = { TableName: 'Users', Item: [1] };
await docClient.put(params).promise();
Drag options to blanks, or click blank then click option'
A'id: 123, name: Alice'
B[ id: 123, name: 'Alice' ]
C{ id: 123, name: 'Alice' }
Did=123, name='Alice'
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets [] which define arrays, not objects.
Passing a string instead of an object for Item.
4fill in blank
hard

Fill both blanks to get an item from the 'Products' table where the 'productId' equals '123'.

DynamoDB
const params = { TableName: '[1]', Key: { [2]: '123' } };
const data = await docClient.get(params).promise();
Drag options to blanks, or click blank then click option'
AProducts
BproductId
CUsers
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong table name like 'Users'.
Using 'id' instead of 'productId' as the key attribute.
5fill in blank
hard

Fill all three blanks to update the 'status' attribute to 'active' for the item with 'userId' 'u123' in the 'Accounts' table.

DynamoDB
const params = {
  TableName: '[1]',
  Key: { [2]: 'u123' },
  UpdateExpression: 'set [3] = :s',
  ExpressionAttributeValues: { ':s': 'active' }
};
await docClient.update(params).promise();
Drag options to blanks, or click blank then click option'
AAccounts
BuserId
Cstatus
DUsers
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong table name like 'Users'.
Using 'id' instead of 'userId' as the key.
Updating the wrong attribute name.