AWS CLI lets you control DynamoDB using simple commands in your terminal. It helps you create, read, update, and delete data without using a web console.
0
0
AWS CLI for DynamoDB
Introduction
You want to quickly add or get data from DynamoDB without writing code.
You need to automate database tasks in scripts or batch jobs.
You want to check or change your DynamoDB tables from your computer.
You are learning DynamoDB and want to try commands step-by-step.
You want to manage DynamoDB in environments without a graphical interface.
Syntax
DynamoDB
aws dynamodb <command> [options]
<command> is the action you want, like create-table or put-item.
[options] are extra details like table name or item data.
Examples
This command creates a table named MyTable with a string key called Id.
DynamoDB
aws dynamodb create-table --table-name MyTable --attribute-definitions AttributeName=Id,AttributeType=S --key-schema AttributeName=Id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
This adds an item with Id 123 and Name Alice to MyTable.
DynamoDB
aws dynamodb put-item --table-name MyTable --item '{"Id": {"S": "123"}, "Name": {"S": "Alice"}}'This fetches the item with Id 123 from MyTable.
DynamoDB
aws dynamodb get-item --table-name MyTable --key '{"Id": {"S": "123"}}'Sample Program
This sequence creates a Students table with StudentId as the key, adds one student named John aged 21, then retrieves John's record.
DynamoDB
aws dynamodb create-table --table-name Students --attribute-definitions AttributeName=StudentId,AttributeType=S --key-schema AttributeName=StudentId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 aws dynamodb put-item --table-name Students --item '{"StudentId": {"S": "S001"}, "Name": {"S": "John"}, "Age": {"N": "21"}}' aws dynamodb get-item --table-name Students --key '{"StudentId": {"S": "S001"}}'
OutputSuccess
Important Notes
Make sure AWS CLI is installed and configured with your AWS credentials before running commands.
JSON data for items must use DynamoDB data types like S for string and N for number.
Provisioned throughput settings control how much read/write capacity your table has.
Summary
AWS CLI lets you manage DynamoDB tables and data using simple terminal commands.
You can create tables, add items, and get items easily with the right commands.
Always format your data correctly and configure AWS CLI before use.