Amazon DynamoDB

@crvouga/mockingbird-service-dynamodb

Stateful Amazon DynamoDB emulator with typed items, expressions, indexes, pagination, transactions, and streams.

Parity: Items, indexes, and transactionsDatabases1 of 1 operationsIn-process fetchNode servermockingbird-dynamodb
$
npm install -D @crvouga/mockingbird-service-dynamodb

Playground

Requests go to the real emulator running in this tab. State persists across requests, and the journal shows what it received. A green dot marks operations whose sample succeeds as-is; others need ids from earlier responses.

Loads the real @crvouga/mockingbird-service-dynamodb into this tab on first send
https://dynamodb.us-east-1.amazonaws.com

Send a request to see the emulator's response.

Operations

1 of 1 operations in the vendored contract are emulated.

MethodPathOperationStatus
POST/DynamoDbRpc

Documentation

The package README, the same file that ships in the npm tarball.Edit on GitHub

Local emulators. Real API contracts. Part of Mockingbird.

Stateful Amazon DynamoDB emulator for the AWS SDK v3 low-level client and DynamoDBDocumentClient. It preserves DynamoDB attribute types while modelling CRUD, expressions, indexes, pagination, batches, transactions, TTL, streams, and conditional writes without contacting AWS.

Install

Shell
npm install -D @crvouga/mockingbird-service-dynamodb

ESM only. Node 22+ or Bun 1.2+.

Usage

Point the SDK's endpoint option at the emulator. Fixture SigV4 credentials are accepted.

TypeScript
import { DynamoDBClient } from "@aws-sdk/client-dynamodb"
import { DynamoDBDocumentClient, GetCommand } from "@aws-sdk/lib-dynamodb"
import { createServer } from "@crvouga/mockingbird-service-dynamodb/server"

// Test setup: seed the emulator and point the AWS SDK client your application uses at it.
const emulator = await createServer({
  tables: [
    {
      name: "records",
      keySchema: [{ AttributeName: "pk", KeyType: "HASH" }],
      items: [{ pk: { S: "fixture" }, status: { S: "ready" } }],
    },
  ],
})
const db = DynamoDBDocumentClient.from(
  new DynamoDBClient({
    endpoint: emulator.url,
    region: "us-east-1",
    credentials: { accessKeyId: "fixture", secretAccessKey: "fixture" },
  }),
)

// Application code: ordinary SDK calls.
const { Item } = await db.send(new GetCommand({ TableName: "records", Key: { pk: "fixture" } }))
// Item: { pk: "fixture", status: "ready" }

await emulator.close() // after the test

Supported operations are CreateTable, DescribeTable, GetItem, PutItem, UpdateItem, DeleteItem, Query, Scan, BatchGetItem, BatchWriteItem, TransactGetItems, and TransactWriteItems. The expression subset includes expression name/value aliases, SET/ADD/REMOVE/DELETE, if_not_exists, attribute_exists, attribute_not_exists, begins_with, comparisons, BETWEEN, AND/OR, projection, conditions, limits, cursors, index ordering, and return values.

Admin and deterministic controls

  • Constructor fixtures define tables, indexes, typed items, and TTL attributes.
  • GET /__admin/tables, /__admin/items?table=…, and /__admin/streams?table=… inspect local state and ordered INSERT/MODIFY/REMOVE records.
  • Advance the shared emulator clock to expire TTL items without sleeps.
  • Fault presets are throttled and one-shot unavailable; generic fault rules can model unprocessed batch responses or eventual-read failures.

The shared runtime also provides reset, timeline, request journal, metrics, faults, and namespace isolation through x-mockingbird-namespace, /__admin/ns/<name>, or SigV4 access-key mappings.

Deliberately not modelled

PartiQL, control-plane operations outside Create/Describe, local/global table replication, IAM policy evaluation, encryption, backups, production capacity accounting, all DynamoDB expression grammar, real asynchronous streams, dashboards, and billing are not modelled.

API

  • DynamoAPI, DynamoAPIOptions, DynamoSeedTable: AWS JSON handler and fixtures.
  • AttributeValue, Item, KeySchemaElement, DynamoIndex, DynamoItem, DynamoTable, StreamRecord: typed state.
  • createRuntime, DynamoRuntime, DynamoRuntimeOptions: full Mockingbird runtime.
  • DYNAMODB_NAMESPACE, DYNAMODB_PRESETS, accessKeyCredential: constants and controls.
  • document, operationIds, supportedOperationIds: generated OpenAPI metadata.
  • createServer, DynamoServerOptions, DEFAULT_PORT, serveTarget from ./server: Node HTTP adapter and CLI integration.

Official oracle: Amazon DynamoDB API Reference.

↑↓ to navigate↵ to open