DynamoDB Cheat Sheet
AWS CLI and boto3 commands plus core DynamoDB concepts like partition keys, indexes, and expressions for NoSQL data modeling.
2 PagesAdvancedMar 20, 2026
AWS CLI Basics
Creating a table and reading/writing items.
bash
aws dynamodb create-table \ --table-name Users \ --attribute-definitions AttributeName=UserId,AttributeType=S \ --key-schema AttributeName=UserId,KeyType=HASH \ --billing-mode PAY_PER_REQUESTaws dynamodb put-item --table-name Users \ --item '{"UserId": {"S": "u1"}, "Email": {"S": "a@b.com"}}'aws dynamodb get-item --table-name Users \ --key '{"UserId": {"S": "u1"}}'
boto3 (Python SDK)
Using the high-level Table resource.
python
import boto3dynamodb = boto3.resource('dynamodb')table = dynamodb.Table('Users')table.put_item(Item={'UserId': 'u1', 'Email': 'a@b.com'})resp = table.get_item(Key={'UserId': 'u1'})item = resp.get('Item')table.update_item( Key={'UserId': 'u1'}, UpdateExpression='SET Email = :e', ExpressionAttributeValues={':e': 'x@y.com'})
Core Concepts
Key building blocks of the DynamoDB model.
- Partition key- hash key that determines how items are distributed across partitions
- Sort key- optional range key that orders items sharing a partition key
- GSI- Global Secondary Index; an alternate partition/sort key for new query patterns
- LSI- Local Secondary Index; alternate sort key, same partition key, set at table creation
- On-demand vs provisioned- pay-per-request billing versus fixed RCU/WCU capacity
- DynamoDB Streams- an ordered, time-limited feed of item-level table changes
Key Operations
The main ways to read and write data.
- GetItem- retrieves a single item by its exact primary key
- Query- retrieves items sharing a partition key, optionally filtered by sort key
- Scan- reads every item in a table; expensive, avoid for large tables
- ConditionExpression- writes only if a condition holds, enabling optimistic locking
- BatchWriteItem- writes or deletes up to 25 items in a single call
- TransactWriteItems- performs an atomic write across multiple items/tables
Pro Tip
Design your table around access patterns first — DynamoDB has no JOINs, so single-table design up front is far cheaper than retrofitting new query patterns onto an existing key schema later.
Was this cheat sheet helpful?
Explore Topics
#DynamoDB#DynamoDBCheatSheet#Database#Advanced#AWSCLIBasics#Boto3PythonSDK#CoreConcepts#KeyOperations#Databases#CloudComputing#CommandLine#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance