0
0
DynamoDBquery~10 mins

Why DynamoDB pairs with Lambda - Test Your Understanding

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

Complete the code to create a DynamoDB client in AWS Lambda.

DynamoDB
const AWS = require('aws-sdk');
const dynamoDB = new AWS.DynamoDB.[1]();
Drag options to blanks, or click blank then click option'
AService
BClient
CConnector
DDocumentClient
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Client' instead of 'DocumentClient' causes errors.
2fill in blank
medium

Complete the code to define a Lambda function that reads an item from DynamoDB.

DynamoDB
exports.handler = async (event) => {
  const params = {
    TableName: 'Users',
    Key: { 'UserId': event.[1] }
  };
  const data = await dynamoDB.get(params).promise();
  return data.Item;
};
Drag options to blanks, or click blank then click option'
AuserId
Bid
CUserId
Dkey
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'UserId' (case sensitive) instead of 'userId'.
3fill in blank
hard

Fix the error in the Lambda function that writes data to DynamoDB.

DynamoDB
exports.handler = async (event) => {
  const params = {
    TableName: 'Orders',
    Item: event.[1]
  };
  await dynamoDB.put(params).promise();
  return { statusCode: 200 };
};
Drag options to blanks, or click blank then click option'
AItem
Bitem
Cdata
Dorder
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'item' causes the function to fail.
4fill in blank
hard

Fill both blanks to create a Lambda function that deletes an item from DynamoDB using the correct key and method.

DynamoDB
exports.handler = async (event) => {
  const params = {
    TableName: 'Products',
    [1]: { 'ProductId': event.productId }
  };
  await dynamoDB.[2](params).promise();
  return { statusCode: 200 };
};
Drag options to blanks, or click blank then click option'
AKey
BItem
CdeleteItem
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Item' instead of 'Key' or 'deleteItem' instead of 'delete'.
5fill in blank
hard

Fill the blanks to update an attribute in DynamoDB using Lambda.

DynamoDB
exports.handler = async (event) => {
  const params = {
    TableName: 'Employees',
    Key: { 'EmployeeId': event.employeeId },
    UpdateExpression: 'set [1] = :val',
    ExpressionAttributeValues: { ':val': event.newValue },
    ReturnValues: '{{BLANK_3}}'
  };
  const result = await dynamoDB.update(params).promise();
  return result.Attributes;
};
Drag options to blanks, or click blank then click option'
ASalary
BN
CUPDATED_NEW
DS
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong attribute name or wrong ReturnValues string.