Complete the code to create a DynamoDB table with a primary key.
aws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=[1],KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
The primary key must match the attribute defined. Here, UserId is the HASH key.
Complete the code to insert an item into the DynamoDB table.
aws dynamodb put-item --table-name Users --item '{"UserId": {"S": "123"}, "Name": {"S": [1]'
String values in DynamoDB JSON must be enclosed in double quotes inside the JSON string.
Fix the error in the query to get an item by primary key.
aws dynamodb get-item --table-name Users --key '{"UserId": {"S": [1]'
The key value must be a string enclosed in double quotes inside the JSON string.
Fill both blanks to create a DynamoDB query filtering items by attribute.
aws dynamodb scan --table-name Users --filter-expression "[1] = :val" --expression-attribute-values '{":val": {"S": [2]'
The filter expression uses the attribute name 'Name' and the value must be a string in double quotes.
Fill all three blanks to update an item attribute in DynamoDB.
aws dynamodb update-item --table-name Users --key '{"UserId": {"S": [1]' --update-expression "SET [2] = :val" --expression-attribute-values '{":val": {"S": [3]'
The key value is the user ID as a string, the attribute to update is 'Name', and the new value is 'Charlie' as a string.