Hands-On: Create a Table
Create the NoteSnap table from the CLI using on-demand billing.
1 min read
You only declare the key attributes when creating a table. Every other attribute is added freely when you write items.
Try it
Terminal
aws dynamodb create-table \
--table-name notesnap-summaries \
--attribute-definitions AttributeName=noteId,AttributeType=S \
--key-schema AttributeName=noteId,KeyType=HASH \
--billing-mode PAY_PER_REQUEST
# Wait until it's ready
aws dynamodb wait table-exists --table-name notesnap-summariesDecoding the flags
AttributeType=S: String. (N= number,B= binary.)KeyType=HASH: this is the partition key. A sort key would beKeyType=RANGE.PAY_PER_REQUEST: on-demand billing. You pay per read and write, and it scales automatically.
On-demand vs. provisioned
| Mode | How it works | Choose it when |
|---|---|---|
| On-demand | Pay per request, scales instantly | New apps, spiky or unpredictable traffic |
| Provisioned | Reserve read/write capacity per second (with optional auto scaling) | Steady, predictable traffic where you want the lowest cost |
Key takeaways
- Only key attributes are declared up front. Everything else is flexible.
- HASH = partition key, RANGE = sort key.
- Start with on-demand billing, and switch to provisioned when traffic is steady and predictable.
Check your understanding
Pick an answer to see the explanation.
1. In the CLI, what does KeyType=RANGE mean?