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
AWS CLI for DynamoDB
📖 Scenario: You are working as a cloud engineer. Your team uses AWS DynamoDB to store user data. You need to practice using the AWS Command Line Interface (CLI) to manage DynamoDB tables and items.
🎯 Goal: Learn how to create a DynamoDB table, add items, query items, and update table settings using AWS CLI commands.
📋 What You'll Learn
Use AWS CLI commands to create and manage DynamoDB tables
Create a table with a primary key
Insert items into the table
Query items by primary key
Update table throughput settings
💡 Why This Matters
🌍 Real World
Managing DynamoDB tables and items via AWS CLI is common for automation, scripting, and quick management without using the AWS Console.
💼 Career
Cloud engineers and developers often use AWS CLI to manage DynamoDB resources efficiently in real projects.
Progress0 / 4 steps
1
Create a DynamoDB table
Use the AWS CLI command aws dynamodb create-table to create a table named Users with a primary key called UserId of type S (string). Set the read and write capacity units to 5 each.
DynamoDB
Hint
Remember to specify the table name, attribute definitions, key schema, and provisioned throughput exactly as shown.
2
Add an item to the Users table
Use the AWS CLI command aws dynamodb put-item to add an item to the Users table. The item should have UserId set to user123 and Name set to John Doe.
DynamoDB
Hint
Use JSON format for the item attributes with correct data types.
3
Query the item by UserId
Use the AWS CLI command aws dynamodb get-item to retrieve the item from the Users table where UserId is user123.
DynamoDB
Hint
Use the --key option with JSON specifying the primary key to get the item.
4
Update the table's provisioned throughput
Use the AWS CLI command aws dynamodb update-table to change the Users table's read capacity units to 10 and write capacity units to 5.
DynamoDB
Hint
Use the update-table command with the correct provisioned throughput values.
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
Step 1: Understand the command purpose
The command aws dynamodb list-tables is designed to list existing tables, not modify or delete them.
Step 2: Match command to action
Listing tables means showing all table names in your current AWS region and account.
Final Answer:
It shows all DynamoDB tables in your AWS account and region. -> Option A
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?
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
Step 1: Check item JSON format requirements
DynamoDB requires attribute values to specify data types, e.g., {"S": "123"} for string.
Step 2: Identify missing data types in JSON
The command uses plain strings without data types, causing a syntax error.
Final Answer:
The item JSON is missing data types for attributes. -> Option A
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?
D. aws dynamodb create-table --table-name Orders --attributes OrderId S OrderDate S --key-schema OrderId HASH OrderDate RANGE --capacity 5 5
Solution
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).
Step 2: Check provisioned throughput format
Provisioned throughput requires ReadCapacityUnits and WriteCapacityUnits with numeric values.