> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DynamoDB table observations

> Read bounded DynamoDB Scan pages into an installation.

Mount `@bijectionhq/app-documents` for one table in an AWS commercial region.
The mount publishes observations at the label the installer binds.
The example uses a table whose contents can be disclosed publicly.

## Mount and start

```ts bijection/app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, label, secret } from "@bijectionhq/bijection";
import documents, { dynamodbTable } from "@bijectionhq/app-documents";

const session = secret();
const table = dynamodbTable("us-east-1", session, label.public);

export default app({ session, table, inventory: documents({ data: label.public, provider: table }) });
```

Grant `inventory.operator` and call `inventory.source.initialize` with:

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{ selection: { mode: "dynamodb", table: { table: "PublicInventory", keys: ["sku"] } } }
```

Read rows with `inventory.documents.list` and the source with
`inventory.source.health`.

Set the AWS session with `bijection secret set session`.
Grant `dynamodb:Scan` on the selected table alone. Supply its partition
key, followed by the sort key if the table has one. Both values must be
strings. The combined JSON key is limited to 384 UTF-8 bytes.

The example uses `label.public`. For protected data, declare a label with
`label()` and pass it to `dynamodbTable` and as the app's `data`.
The installation charges retained work against the app's `data` label's
reservation. See [installer-bound labels](https://docs.bijection.com/integrations/native-connectors.md#installer-bound-labels).

## Paging and recovery

The app uses one strongly consistent Scan item per request and accepts
responses up to 36 KiB. It preserves the DynamoDB AttributeValue encoding
in each record, including exact number strings. Each page lands with its
`LastEvaluatedKey`, which the next request uses as `ExclusiveStartKey`.
After the end of the table, the mount begins another traversal on its
next poll.

A Scan can see writes made between pages. The app makes no snapshot
or deletion-by-absence inference.
An oversize or invalid answer leaves the cursor in place. Use `source.health`
to get the revision for polling, pausing, resuming, or resetting a source.
A reset starts a new traversal and preserves previously observed items.

## Capture DynamoDB Streams changes

Use one Documents mount per stream ARN with `dynamodbStreams` in place
of `dynamodbTable`. Use the stream's AWS region and the installer-bound
label. Grant `dynamodb:DescribeStream`, `dynamodb:GetShardIterator` and
`dynamodb:GetRecords` on the stream ARN. Enable `NEW_IMAGE` or
`NEW_AND_OLD_IMAGES` on the table.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  selection: {
    mode: "dynamodb-streams",
    stream: {
      arn: "arn:aws:dynamodb:us-west-2:111122223333:table/Forum/stream/2015-05-20T20:51:10.252",
      keys: ["Id"],
    },
  },
}
```

The mount pages through the stream topology automatically. It reads a
child only after its parent has drained, and rotates among independent
shards. The initial baseline starts at the oldest available events in the
retained topology. An ancestor already absent from that first discovery
is outside the baseline.

Each exchange accepts up to 24 shard descriptions or one event, within a
15 KiB encoded answer limit. The mount upserts INSERT and MODIFY images
and applies REMOVE events using the same string keys as Scan. It commits
the data change and the shard's sequence together. An expired iterator
reopens at the retained sequence or the shard's starting sequence.

DynamoDB retains records for 24 hours. A trimmed position, lost
undrained shard, or missing parent discovered after the baseline stops
advancement. Review `source.health` before explicitly resetting the
source. Configure a new mount for a replacement stream ARN. Scan and
Streams use separate mounts. Deletion by absence is outside both modes.

[DynamoDB Streams shard lineage](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html) ·
[DynamoDB Streams API](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_GetRecords.html) ·
[Amazon DynamoDB Scan API](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.