# aws dynamodb get-item

AWS CLI commands · Updated 16 November 2026

**Short answer:** aws dynamodb get-item --table-name my-table --key '{"pk":{"S":"USER#42"}}' returns a single item by its full primary key. You must give the partition key and, if the table has one, the sort key; if no item matches, the command succeeds and simply prints nothing instead of raising an error.

## What the command does

`GetItem` is the cheapest, fastest read in DynamoDB: one exact key, one item, at most 400 KB. It reads with eventual consistency unless you add `--consistent-read`, which doubles the read cost but guarantees you see the latest successful write.

It cannot search. You need the complete key. To find items by a non-key attribute, use [query](https://cloudconsole.dev/cli/dynamodb-query) on an index or [scan](https://cloudconsole.dev/cli/dynamodb-scan).

## Syntax

```
aws dynamodb get-item --table-name <table> \
  --key '{"<pk>":{"S":"..."}, "<sk>":{"S":"..."}}' \
  [--consistent-read] \
  [--projection-expression "a, b, #c"] \
  [--expression-attribute-names '{"#c":"..."}']
```

## Worked examples

**Read an item from a table with a composite key:**

```
aws dynamodb get-item --table-name orders \
  --key '{"pk":{"S":"CUSTOMER#4711"},"sk":{"S":"ORDER#2026-11-16#0042"}}'
```

Output shape:

```
{
  "Item": {
    "pk": {"S": "CUSTOMER#4711"},
    "sk": {"S": "ORDER#2026-11-16#0042"},
    "status": {"S": "PAID"},
    "total": {"N": "129.5"}
  }
}
```

**Strongly consistent read of selected attributes**, printing plain values:

```
aws dynamodb get-item --table-name orders \
  --key '{"pk":{"S":"CUSTOMER#4711"},"sk":{"S":"ORDER#2026-11-16#0042"}}' \
  --consistent-read \
  --projection-expression "#s, total" \
  --expression-attribute-names '{"#s":"status"}' \
  --query "Item.[status.S, total.N]" --output text
```

**Key from a file**, which avoids quoting trouble on Windows:

```
aws dynamodb get-item --table-name users --key file://key.json
```

**Check whether an item exists** in a shell script:

```
found=$(aws dynamodb get-item --table-name users \
  --key '{"userId":{"S":"42"}}' \
  --query "Item.userId.S" --output text)
if [ "$found" = "None" ]; then echo "no such user"; fi
```

Querying one key attribute keeps the comparison simple: text output prints `None` when the item is absent.

**Read several known keys in one call** with `batch-get-item`, which accepts up to 100 keys:

```
aws dynamodb batch-get-item --request-items '{"users":{"Keys":[{"userId":{"S":"42"}},{"userId":{"S":"43"}}],"ProjectionExpression":"userId, email"}}' \
  --query "Responses.users[].[userId.S, email.S]" --output text
```

Anything DynamoDB could not read in that call comes back in `UnprocessedKeys`; retry those.

## Key options

| Option | Notes |
|---|---|
| `--key` | The full primary key in typed JSON. Must name exactly the key attributes, with the right types. |
| `--consistent-read` | Return the latest committed value. Twice the read units of an eventually consistent read. |
| `--projection-expression` | Return only these attributes. Read cost is still based on the full item size. |
| `--return-consumed-capacity TOTAL` | Show how many read units the call used; handy when sizing a table. |

## Gotchas

- **Missing item = empty output, not an error.** The response just has no `Item` key. With `--query Item --output text` you get `None`. Check for it explicitly.
- **Key type mismatch is an error.** Passing `{"N":"42"}` when the key is a string, or leaving out the sort key, gives [The provided key element does not match the schema](https://cloudconsole.dev/errors/dynamodb-key-element-does-not-match-schema).
- **Numbers are strings in JSON.** Write `{"N":"42"}`, with the quotes.
- **No wildcards.** `get-item` cannot return "all items for a key prefix"; that is a query with `begins_with`.
- **Wrong Region looks like a missing table.** A [ResourceNotFoundException](https://cloudconsole.dev/errors/dynamodb-resourcenotfound) usually means the CLI is pointed at another Region or account.

## Questions

### How do I get all items from a DynamoDB table with the CLI?

get-item only reads one item. Use aws dynamodb scan --table-name my-table for everything, or query for all items under one partition key.

### How do I get several items at once?

Use aws dynamodb batch-get-item with a --request-items JSON listing the keys per table. It reads up to 100 items per call and may return UnprocessedKeys that you need to retry.

### How do I list DynamoDB tables from the CLI?

Run aws dynamodb list-tables. It returns table names in the current Region only, so add --region to check others.

## When this happens away from your desk

Checking a single record is often all you need to confirm a customer's report. CloudConsole is built to show AWS resources and alarms on a phone, so the first look at a problem does not need a laptop.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [aws dynamodb get-item (AWS CLI Command Reference)](https://docs.aws.amazon.com/cli/latest/reference/dynamodb/get-item.html)
- [Working with items and attributes (Developer Guide)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html)

## Related

- [aws dynamodb query](https://cloudconsole.dev/cli/dynamodb-query)
- [aws dynamodb put-item](https://cloudconsole.dev/cli/dynamodb-put-item)
- [ValidationException: The provided key element does not match the schema](https://cloudconsole.dev/errors/dynamodb-key-element-does-not-match-schema)
- [ResourceNotFoundException: Requested resource not found (DynamoDB)](https://cloudconsole.dev/errors/dynamodb-resourcenotfound)
- [aws dynamodb describe-table](https://cloudconsole.dev/cli/dynamodb-describe-table)
- [aws dynamodb batch-write-item](https://cloudconsole.dev/cli/dynamodb-batch-write-item)

---

Source: https://cloudconsole.dev/cli/dynamodb-get-item

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
