A hands-on DynamoDB lab in fourteen slides, in the console and the CLI: create the table project-sessions, turn on TTL and write 200 sessions with a boto3 script, read a live session and an expired one, compare a Query with a Scan by the read units each consumes, add the index user-index and query it, turn on the table's stream and read a change from it, and clean up.
The slides
The tool is a hands-on lab in fourteen slides, one step each, with the steps to follow beside a terminal and a picture
of the table, its settings and the reads made so far:
- Introduction: what the lab makes.
- 1. The table
- Prepare the computer: the CLI as
jane, and boto3. - Create the table project-sessions: partition key
session_id, on-demand. - Read the table from the CLI: its status, key and capacity mode.
- 2. Sessions with TTL
- Turn on TTL: on the attribute
expires_at. - Write 200 sessions with boto3:
sessions.py, every tenth session already expired. - Read one session by its key:
GetItem, eventually and strongly consistent. - Read an expired session: still there until TTL deletes it.
- 3. Query and Scan
- Compare a Query with a Scan: 0.5 read units against 2.0, and a Query DynamoDB refuses.
- Add the index user-index:
user_id and expires_at. - Query the index: one user's sessions, and a key condition that leaves the expired ones unread.
- 4. Streams
- Turn on the stream: new and old images.
- Read a change from the stream: a
MODIFY record, before and after.
- 5. Clean up: the table.
The buttons on the left and right edges move between slides. So do the arrow keys and a swipe.
The lab starts where
Getting Started with AWS ends: the CLI works as jane.
The slides
Amazon DynamoDB and Choosing a Database explain what it uses.
The placeholders
The account ID is AWS's documentation placeholder, 111122223333. The Unix times start at 1794826800, a time on
2026-11-16; yours are the time you run the script. The consumed capacity is worked out from the Developer Guide's rules,
not yet measured in a real run.
Sources