Bird
Raised Fist0
DynamoDBquery~20 mins

AWS CLI for DynamoDB - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
DynamoDB AWS CLI Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What is the output of this AWS CLI command?
You run this command to list all tables in your DynamoDB account:

aws dynamodb list-tables --region us-east-1

What will the command output if you have exactly two tables named Users and Orders?
DynamoDB
aws dynamodb list-tables --region us-east-1
A{"TableNames": ["Users", "Orders"]}
B{"Tables": ["Users", "Orders"]}
C{"TableList": ["Users", "Orders"]}
D}]"sredrO" ,"sresU"[ :"semaNelbaT"{
Attempts:
2 left
💡 Hint
Look for the exact key name that AWS CLI uses to list tables.
Configuration
intermediate
2:00remaining
Which AWS CLI command creates a DynamoDB table with a primary key named 'Id' of type string?
You want to create a DynamoDB table named Products with a simple primary key called Id of type string. Which command will do this correctly?
Aaws dynamodb create-table --table-name Products --attribute-definitions AttributeName=Id,AttributeType=S --key-schema AttributeName=Id,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Baws dynamodb create-table --table-name Products --attribute-definitions AttributeName=Id,AttributeType=N --key-schema AttributeName=Id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Caws dynamodb create-table --table-name Products --attribute-definitions AttributeName=Id,AttributeType=S --key-schema AttributeName=Id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Daws dynamodb create-table --table-name Products --attribute-definitions AttributeName=Id,AttributeType=S --key-schema AttributeName=Id,KeyType=HASH
Attempts:
2 left
💡 Hint
The primary key must be of type HASH and attribute type S for string.
security
advanced
2:00remaining
What error occurs if you try to delete a DynamoDB table that does not exist using AWS CLI?
You run this command:

aws dynamodb delete-table --table-name NonExistentTable

What error message will AWS CLI return?
AAn error with code ValidationException indicating invalid table name
BAn error with code AccessDeniedException indicating you lack permissions
CNo error; the command succeeds silently
DAn error with code ResourceNotFoundException indicating the table does not exist
Attempts:
2 left
💡 Hint
Deleting a non-existing resource usually returns a 'not found' error.
Architecture
advanced
2:00remaining
Which AWS CLI command correctly updates the provisioned throughput of a DynamoDB table named 'Orders' to 10 read and 5 write units?
You want to increase the read capacity units to 10 and write capacity units to 5 for the 'Orders' table. Which command is correct?
Aaws dynamodb update-table --table-name Orders --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5
Baws dynamodb update-table --table-name Orders --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=10
Caws dynamodb update-table --table-name Orders --read-capacity 10 --write-capacity 5
Daws dynamodb update-table --table-name Orders --capacity Read=10,Write=5
Attempts:
2 left
💡 Hint
Provisioned throughput requires both read and write capacity units specified in a single option.
🧠 Conceptual
expert
2:00remaining
What is the output of this AWS CLI command querying a DynamoDB table?
You run this command to query the 'Users' table for items where 'UserId' equals '123':

aws dynamodb query --table-name Users --key-condition-expression "UserId = :v1" --expression-attribute-values '{":v1":{"S":"123"}}'

Assuming the table has one item with UserId '123' and attribute 'Name' with value 'Alice', what will the output JSON contain?
DynamoDB
aws dynamodb query --table-name Users --key-condition-expression "UserId = :v1" --expression-attribute-values '{":v1":{"S":"123"}}'
A{"Items": [{"UserId": "123", "Name": "Alice"}], "Count": 1}
B{"Items": [{"UserId": {"S": "123"}, "Name": {"S": "Alice"}}], "Count": 1, "ScannedCount": 1}
C{"Results": [{"UserId": {"S": "123"}, "Name": {"S": "Alice"}}], "Count": 1}
D{"Items": [{"UserId": {"N": "123"}, "Name": {"S": "Alice"}}], "Count": 1, "ScannedCount": 1}
Attempts:
2 left
💡 Hint
DynamoDB returns attribute values with their types in the output.

Practice

(1/5)
1. What does the AWS CLI command aws dynamodb list-tables do?
easy
A. It shows all DynamoDB tables in your AWS account and region.
B. It deletes all DynamoDB tables in your AWS account.
C. It creates a new DynamoDB table.
D. It updates the items in a DynamoDB table.

Solution

  1. Step 1: Understand the command purpose

    The command aws dynamodb list-tables is designed to list existing tables, not modify or delete them.
  2. Step 2: Match command to action

    Listing tables means showing all table names in your current AWS region and account.
  3. Final Answer:

    It shows all DynamoDB tables in your AWS account and region. -> Option A
  4. Quick Check:

    List tables = Show tables [OK]
Hint: List tables command always shows existing tables [OK]
Common Mistakes:
  • Confusing list-tables with delete-table
  • Thinking it creates or updates tables
  • Assuming it shows table data instead of names
2. Which AWS CLI command syntax correctly adds an item to a DynamoDB table named Books with a primary key ISBN and a title attribute?
easy
A. aws dynamodb add-item --table Books --item '{ISBN: 12345, Title: Cloud Basics}'
B. aws dynamodb put-item --table-name Books --item '{"ISBN": {"S": "12345"}, "Title": {"S": "Cloud Basics"}}'
C. aws dynamodb insert-item --table-name Books --item '{"ISBN": "12345", "Title": "Cloud Basics"}'
D. aws dynamodb put-item --table Books --data '{"ISBN": "12345", "Title": "Cloud Basics"}'

Solution

  1. Step 1: Identify correct command and parameters

    The correct command to add an item is put-item with --table-name and --item parameters.
  2. Step 2: Check JSON format for item

    The item must be a JSON string with attribute names and types, e.g., {"ISBN": {"S": "12345"}} where "S" means string type.
  3. Final Answer:

    aws dynamodb put-item --table-name Books --item '{"ISBN": {"S": "12345"}, "Title": {"S": "Cloud Basics"}}' -> Option B
  4. Quick Check:

    Put-item + correct JSON format = aws dynamodb put-item --table-name Books --item '{"ISBN": {"S": "12345"}, "Title": {"S": "Cloud Basics"}}' [OK]
Hint: Use put-item with --item JSON including data types [OK]
Common Mistakes:
  • Using wrong command like add-item or insert-item
  • Missing data types in JSON attributes
  • Using --table instead of --table-name
3. What will be the output of this AWS CLI command?
aws dynamodb get-item --table-name Users --key '{"UserId": {"S": "user123"}}' --projection-expression "Name, Age"

Assuming the table has an item with UserId 'user123', Name 'Alice', Age 30, and Email 'alice@example.com'.
medium
A. Returns only the Email attribute.
B. Returns all attributes including Email.
C. Returns an error because projection-expression is invalid.
D. Returns only the Name and Age attributes of the item.

Solution

  1. Step 1: Understand get-item with projection-expression

    The --projection-expression limits returned attributes to those listed, here "Name, Age".
  2. Step 2: Check expected output

    Since Email is not in projection-expression, it will not be returned. Only Name and Age appear.
  3. Final Answer:

    Returns only the Name and Age attributes of the item. -> Option D
  4. Quick Check:

    Projection-expression filters attributes = Returns only the Name and Age attributes of the item. [OK]
Hint: Projection-expression returns only listed attributes [OK]
Common Mistakes:
  • Assuming all attributes return by default
  • Thinking projection-expression causes error
  • Confusing projection-expression with filter-expression
4. You run this command but get an error:
aws dynamodb put-item --table-name Products --item '{"ProductId": "123", "Name": "Pen"}'

What is the likely cause of the error?
medium
A. The item JSON is missing data types for attributes.
B. The table name is incorrect.
C. The AWS CLI is not installed.
D. The command should use --update-item instead of --put-item.

Solution

  1. Step 1: Check item JSON format requirements

    DynamoDB requires attribute values to specify data types, e.g., {"S": "123"} for string.
  2. Step 2: Identify missing data types in JSON

    The command uses plain strings without data types, causing a syntax error.
  3. Final Answer:

    The item JSON is missing data types for attributes. -> Option A
  4. Quick Check:

    Missing data types in item JSON causes error [OK]
Hint: Always include data types like {"S": "value"} in item JSON [OK]
Common Mistakes:
  • Ignoring data type syntax in item JSON
  • Assuming --put-item is invalid command
  • Not verifying table name correctness
5. You want to create a DynamoDB table named Orders with a primary key OrderId (string) and a sort key OrderDate (string). Which AWS CLI command is correct?
hard
A. aws dynamodb create-table --table-name Orders --attribute-definitions OrderId=S OrderDate=S --key-schema OrderId=HASH OrderDate=RANGE --provisioned-throughput Read=5,Write=5
B. aws dynamodb create-table --table Orders --attributes OrderId=S,OrderDate=S --keys OrderId=HASH,OrderDate=RANGE --throughput 5 5
C. aws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=OrderId,AttributeType=S AttributeName=OrderDate,AttributeType=S --key-schema AttributeName=OrderId,KeyType=HASH AttributeName=OrderDate,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
D. aws dynamodb create-table --table-name Orders --attributes OrderId S OrderDate S --key-schema OrderId HASH OrderDate RANGE --capacity 5 5

Solution

  1. Step 1: Identify correct command syntax for create-table

    The correct syntax uses --attribute-definitions with AttributeName and AttributeType, and --key-schema with AttributeName and KeyType (HASH for partition key, RANGE for sort key).
  2. Step 2: Check provisioned throughput format

    Provisioned throughput requires ReadCapacityUnits and WriteCapacityUnits with numeric values.
  3. Final Answer:

    aws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=OrderId,AttributeType=S AttributeName=OrderDate,AttributeType=S --key-schema AttributeName=OrderId,KeyType=HASH AttributeName=OrderDate,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 -> Option C
  4. Quick Check:

    Create-table syntax with attribute-definitions and key-schema = aws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=OrderId,AttributeType=S AttributeName=OrderDate,AttributeType=S --key-schema AttributeName=OrderId,KeyType=HASH AttributeName=OrderDate,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 [OK]
Hint: Use --attribute-definitions and --key-schema with correct keys [OK]
Common Mistakes:
  • Using wrong flags like --table or --attributes
  • Incorrect key schema format
  • Wrong provisioned throughput parameter names