Canonical: https://weaveos.com/reference/amazon-dynamodb/query-items-by-partition-key

1. [Software capabilities](https://weaveos.com/reference)
2. /[Amazon DynamoDB](https://weaveos.com/reference/amazon-dynamodb)
3. /Query DynamoDB items by partition key

[![](https://weaveos.com/reference/logos/amazon-dynamodb.svg)Amazon DynamoDB](https://weaveos.com/reference/amazon-dynamodb)

# Query DynamoDB items by partition key

Use a key condition to read items for one partition key, with an optional sort-key condition. Run the query in the AWS CLI or page through the results in Go.

Documentation reviewed November 27, 2026 · 2 methods with sources

## Ways to do it

1. [1CLI: aws dynamodb query](https://weaveos.com/reference/amazon-dynamodb/query-items-by-partition-key#method-1)
2. [2SDK: dynamodb.NewQueryPaginator](https://weaveos.com/reference/amazon-dynamodb/query-items-by-partition-key#method-2)

CLI

### aws dynamodb query

Use --table-name and --key-condition-expression with typed placeholder values. Add --index-name to query a secondary index.

[Read source: AWS CLI DynamoDB query](https://docs.aws.amazon.com/cli/latest/reference/dynamodb/query.html)

- Requirements

  AWS CLI with dynamodb:Query permission for the table or index, its name, and a partition key value.

- Limitations

  DynamoDB evaluates up to 1 MB in one request before applying a filter. Put key attributes in the key condition.

Example shell

Copy

```
aws dynamodb query --table-name ExampleTable --key-condition-expression 'pk = :key' --expression-attribute-values '{":key":{"S":"example"}}'
```

SDK

### dynamodb.NewQueryPaginator

Set TableName, KeyConditionExpression, and ExpressionAttributeValues on QueryInput. Use the paginator to follow each continuation key.

[Read source: AWS SDK for Go v2 DynamoDB Query](https://github.com/aws/aws-sdk-go-v2/blob/fab6ce7049daa93f9ace2bb14039f41c8a00504a/service/dynamodb/api_op_Query.go)

- Requirements

  An AWS SDK for Go v2 DynamoDB client with credentials, the table’s Region, and dynamodb:Query permission for the table or index.

- Limitations

  A filtered page can have no items and still have a LastEvaluatedKey. Continue until the paginator has no more pages.

## More from Amazon DynamoDB

[View all 1 Amazon DynamoDB tasks](https://weaveos.com/reference/amazon-dynamodb)
