Get All Items from DynamoDB with the AWS CLI
The AWS CLI hides the pagination. aws dynamodb scan makes as many 1 MB service calls as the table needs and prints one combined result, so the command that reads ten items and the command that reads ten million are the same command.
That is the convenience and the trap. The call count, the memory, and the bill all scale with the table while the line stays one line.
Code
aws dynamodb scan --table-name 'Music'The combined output holds every item in the table:
{
"Items": [
{"Artist": {"S": "Arturo Sandoval"}, "SongTitle": {"S": "Cubano Chant"}, ...}
],
"Count": 1287,
"ScannedCount": 1287
}Explanation
--no-paginateis the single-call switch — it stops the CLI following the cursor, so you get the first page and nothing else. Fine for a look, wrong for a full read (how the cursor works).--page-sizechanges the call count, not the output — AWS puts it plainly: "Changing the page size doesn't affect the output; it affects only the number of API calls that need to be made to generate the output." Reach for it when a large page times out, never to save money. The read cost is identical either way.--max-itemsis where the output stops andNextTokenstarts — it prints that many items plus a resume token for--starting-token. Set it and--page-sizeto the same number: AWS warns that different values "can get unexpected results with missing or duplicated items".--queryruns on your machine — it is JMESPath over the printed result, applied after every item has been read and billed.--projection-expression(plus--expression-attribute-namesfor reserved words) is the one DynamoDB sees, and it shrinks the response rather than the bill. A--filter-expressionalso drops items after they are charged (Scan with a filter).- Everything buffers, then meets a pager — the CLI accumulates every page before printing, and CLI v2 sends the result through
lesson macOS and Linux ormoreon Windows by default. On a large table that is a memory spike and a stalled terminal at once. Add--no-cli-pager, or setAWS_PAGERto an empty string, and slice with--max-items. - Parallel scan works from the shell too — run N copies with
--segment i --total-segments N, each auto-paginating its own slice. Same total cost, much lower wall clock (when it is worth it).
Do it visually
A one-line command can be an expensive command. The DynamoDB pricing calculator puts a number on a full read of your table before you run it.
DynoTable pages through the table in a grid rather than a terminal buffer, and will export the Scan behind that grid back out as an aws dynamodb command. Download DynoTable.
Related examples
- Get all items in Node.js — the same full read with an explicit loop.
- Get all items in Python — the same full read with boto3's paginator.
- DynamoDB Scan with the AWS CLI — scanning with a
--filter-expression. - Parallel scans — Segment/TotalSegments, worker counts, and when to bother.
- Why is my DynamoDB Scan slow and expensive? — the cost model and how to avoid it.
- DynamoDB ProvisionedThroughputExceededException — reading the whole table is the classic way to hit it.
- "The provided starting key is invalid" — a mangled resume key in the pagination loop.
References
- Scan — Amazon DynamoDB API Reference
- scan — AWS CLI Command Reference
- Using AWS CLI pagination options — AWS CLI User Guide
- DynamoDB read and write operations (capacity unit consumption) — Amazon DynamoDB Developer Guide
Last verified 2026-07-28 against the official AWS documentation linked above.