How I can work with Amazon's Dynamodb Local in Node?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
DynamoDB Local is a downloadable version of Amazon DynamoDB that runs on your machine, allowing you to develop and test applications without connecting to AWS or incurring costs. In Node.js, you connect to DynamoDB Local by configuring the AWS SDK with a custom endpoint pointing to http://localhost:8000. The rest of the API is identical to production DynamoDB — same methods, same parameters, same response formats. This makes it easy to develop locally and deploy to AWS with only an endpoint configuration change.
Setting Up DynamoDB Local
The -sharedDb flag uses a single database file for all regions and credentials, simplifying local development. Without it, each credentials/region combination gets a separate database.
Connecting with AWS SDK v3
For DynamoDB Local, credentials can be any non-empty string — they are not validated. The region is required by the SDK but ignored locally when using -sharedDb.
Creating a Table
CRUD Operations
Switching Between Local and Production
This pattern keeps your application code identical between local development and production. Only the DynamoDB client configuration changes.
Integration Testing with DynamoDB Local
Using -inMemory flag makes DynamoDB Local store data in memory only, providing a clean state for each test run.
Common Pitfalls
- Forgetting the
endpointconfiguration: Withoutendpoint: "http://localhost:8000", the SDK connects to the real AWS DynamoDB service, which requires valid credentials and incurs costs. Always verify the endpoint is set for local development. - DynamoDB Local not supporting all features: DynamoDB Local does not support DynamoDB Streams, TTL expiration, global tables, or some IAM-based access control features. Test these features against the real AWS service in a staging environment.
- Port conflict with other services: Port 8000 is commonly used by other applications. If DynamoDB Local fails to start, check for port conflicts and use a different port:
docker run -p 8001:8000 amazon/dynamodb-localwithendpoint: "http://localhost:8001". - Data loss on container restart: Without volume mounting, DynamoDB Local in Docker loses all data when the container stops. Mount a volume for persistence:
docker run -v ./dynamodb-data:/home/dynamodblocal/data -p 8000:8000 amazon/dynamodb-local. - Using SDK v2 syntax with SDK v3: AWS SDK v3 uses a modular client pattern (
new DynamoDBClient()) and command objects (new PutCommand()), while SDK v2 usesnew AWS.DynamoDB()with callback/promise methods. Mixing the two causes import errors and runtime failures.
Summary
- Run DynamoDB Local via Docker:
docker run -p 8000:8000 amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb - Connect with AWS SDK v3 by setting
endpoint: "http://localhost:8000"and dummy credentials - Use
DynamoDBDocumentClientfor simplified JavaScript-native data types - Switch between local and production using an environment variable for the endpoint
- Use
-inMemoryflag for clean test runs and-sharedDbfor simplified local development - The API is identical between local and production — only the client configuration changes
Related reading
- How I create new namespace in Kubernetes
- How is Amazon DynamoDB throughput calculated and limited?
- How is Amazon DynamoDB throughput calculated and limited?
- How is Docker Swarm different than Kubernetes?
- How is airflow database managed periodically?
- How is Cassandra designed to avoid the need for load balancers?
- How is an HTTP POST request made in node.js?
- How is null true a string?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.