Skip to content

Replace DynamoDB Local

fdyno-local is a development image. One container runs one FoundationDB process and fdyno on port 8000. It accepts the command line of amazon/dynamodb-local, so most setups change only the image name.

For development and tests only. The container has no authentication: it accepts any access key and does not check signatures, as DynamoDB Local does (see Security). It has one FoundationDB process and no replication. For production, read Deploy.

 amazon/dynamodb-local             fdyno-local
 ┌──────────────────────┐          ┌───────────────────────────────┐
 │ java DynamoDBLocal   │   ──▶    │ fdyno-local (entrypoint)      │
 │ SQLite or in memory  │          │  ├─ fdbserver 127.0.0.1:4500  │
 │ port 8000            │          │  └─ dynodb    0.0.0.0:8000    │
 └──────────────────────┘          └───────────────────────────────┘

Build the image

The image is not published. Build it from a checkout of the repository. The first command builds dist/linux-<arch>/dynodb in the pinned build container (Docker or Podman):

scripts/release/build-in-container.sh --arch amd64      # arm64 on Apple silicon
docker build -f deploy/local/Dockerfile -t fdyno-local:dev .
docker run --rm -p 8000:8000 fdyno-local:dev

Check it with the AWS CLI. Any key and any Region work:

AWS_ACCESS_KEY_ID=dummy AWS_SECRET_ACCESS_KEY=dummy \
  aws dynamodb list-tables --endpoint-url http://localhost:8000 --region us-east-1

What is different

DynamoDB Local fdyno-local
Access key and secret Any; the access key has letters and digits only (since 2.0) Any
Signature Not checked Not checked
Region Any Any
Data per key and Region One database per access key and Region; -sharedDb makes one Always one database, as with -sharedDb. See test isolation
Global secondary index Updated in the same request Eventually consistent, as in DynamoDB. See read your write
-inMemory Data in the JVM heap Data in the container, deleted when the container starts again
-dbPath DIR SQLite file in DIR FoundationDB data in DIR; kept across restarts
-port N Listens on N Listens on N
-cors, -delayTransientStatuses, -optimizeDbBeforeStartup, -disableTelemetry Supported Accepted and ignored
Table status after CreateTable ACTIVE at once ACTIVE at once
Behavior An emulator The same server as production: compatibility, limits
Start time to the first answer, empty database 1.4–1.5 s 1.9–2.0 s
Readiness Port open Port open after FoundationDB answers; GET /readyz; the log line Initializing DynamoDB Local
Container user dynamodblocal (UID 1000) UID 65532

Image entrypoint java and JVM arguments (-Djava.library.path=..., -Xmx...) are accepted and ignored. Errors and limits are fdyno's, not DynamoDB Local's. For example, an item is at most 48,000 bytes (limits), and a wrong expression gets the same ValidationException text as DynamoDB.

Read your write on an index

DynamoDB Local updates a global secondary index in the same request. DynamoDB and fdyno update it after the write returns. A test that writes an item and at once queries an index can see nothing on fdyno, and on DynamoDB. In a test on one fdyno-local container (500 writes, one at a time), the first index query after the write missed the item 488 times. The item appeared in the index 7.4 ms (p99) after PutItem returned; the first write after CreateTable took 617 ms.

Do one of these in tests:

  • Read the base table with ConsistentRead=True. It sees the write at once.
  • Poll the index query until the item appears, with a deadline:
import time

def query_index_until(client, deadline_s=5, **query):
    end = time.monotonic() + deadline_s
    while True:
        items = client.query(**query)["Items"]
        if items or time.monotonic() > end:
            return items
        time.sleep(0.02)

Test isolation

fdyno has one database for every access key and Region. Tests that depend on DynamoDB Local's separate database per key or Region must separate themselves:

  • Give each test or test class its own table-name prefix, for example f"{uuid4().hex[:8]}-orders", and delete its tables at the end.
  • Or start one container per test class. A new container starts with an empty database.

docker-compose

Change the image. Keep the command:

services:
  dynamodb-local:
    image: fdyno-local:dev            # was amazon/dynamodb-local:latest
    command: "-jar DynamoDBLocal.jar -sharedDb -dbPath /home/dynamodblocal/data"
    ports:
      - "8000:8000"
    volumes:
      - dynamodb-data:/home/dynamodblocal/data
    healthcheck:
      test: ["CMD", "fdyno-local", "health"]
      interval: 2s
      retries: 30

volumes:
  dynamodb-data: {}

A named volume works without changes. A bind-mounted host directory must be writable by UID 65532: sudo chown 65532 ./docker/dynamodb, or add user: root to the service. DynamoDB Local has the same rule for its UID 1000.

Services that wait for the database use the health check:

    depends_on:
      dynamodb-local:
        condition: service_healthy

testcontainers

Go

The modules/dynamodb module sets DynamoDB Local's entrypoint (java) and command; fdyno-local accepts both. Change only the image:

ctr, err := tcdynamodb.Run(ctx, "fdyno-local:dev", tcdynamodb.WithSharedDB())

WithSharedDB reuses a container named tc_dynamodb_local. After you change the image, remove the old container once: docker rm -f tc_dynamodb_local.

Java, Python, Node.js

These have no DynamoDB module. Use a generic container and wait for the port or for DynamoDB Local's log line; fdyno-local prints it when it is ready.

GenericContainer<?> db = new GenericContainer<>(DockerImageName.parse("fdyno-local:dev"))
    .withExposedPorts(8000)
    .waitingFor(Wait.forListeningPort());
from testcontainers.core.container import DockerContainer
from testcontainers.core.waiting_utils import wait_for_logs

with DockerContainer("fdyno-local:dev").with_exposed_ports(8000) as c:
    wait_for_logs(c, "Initializing DynamoDB Local", timeout=60)
    endpoint = f"http://{c.get_container_host_ip()}:{c.get_exposed_port(8000)}"
const db = await new GenericContainer("fdyno-local:dev").withExposedPorts(8000).start();
const endpoint = `http://${db.getHost()}:${db.getMappedPort(8000)}`;

Clients keep their dummy keys and any Region.

serverless-offline

serverless-dynamodb downloads and runs DynamoDB Local's JAR. Run fdyno-local instead, and tell the plugin not to start its own:

custom:
  serverless-dynamodb:
    stages: [dev]
    start:
      noStart: true        # fdyno-local runs on port 8000
      port: 8000
      migrate: true        # creates the tables in resources
      seed: true
docker run -d --rm -p 8000:8000 fdyno-local:dev
npx serverless offline start

dynamodb-admin and NoSQL Workbench

DYNAMO_ENDPOINT=http://localhost:8000 npx dynamodb-admin

dynamodb-admin signs with its own key (key). fdyno-local has one database, so it shows the tables that the application created with any key. DynamoDB Local shows them only with -sharedDb.

NoSQL Workbench is not tested. Its DynamoDB Local connection (host localhost, port 8000) signs with its own key; fdyno-local accepts any key.

AWS CLI and SDKs

export AWS_ACCESS_KEY_ID=dummy AWS_SECRET_ACCESS_KEY=dummy AWS_DEFAULT_REGION=us-east-1
export AWS_ENDPOINT_URL=http://localhost:8000
aws dynamodb list-tables

SDKs use the same endpoint. See Compatibility.