How to set up DynamoDB locally

Do you know that can use the local version of Amazon DynamoDB to develop and test applications without having to access the DynamoDB web service?
This local version helps you save on throughput, data storage, and data transfer fees. Moreover, it enables you to test your applications without having to worry about internet connectivity.

As a developer, you can use the local version of DynamoDB to simulate real-world scenarios and test the limits of your application. You can also use it to debug and troubleshoot issues in a controlled environment. By using the local version, you can speed up your development process and reduce your overall development costs.

Setup with Docker compose

A local version of Amazon DynamoDB is available as a Docker image.
For more information, see dynamodb-local.

To install and run DynamoDB locally with Docker compose (Docker must be installed):

Copy the following code to a file and save it as docker-compose.yml.

version: '3.8'
services:
  dynamodb-local:
    command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
    image: "amazon/dynamodb-local:latest"
    container_name: dynamodb-local
    ports:
      - "8000:8000"
    volumes:
      - "./docker/dynamodb:/home/dynamodblocal/data"
    working_dir: /home/dynamodblocal

Run the following command:

docker-compose up

Your local DynamoDB is ready to be used.
You can use the AWS CLI to interact with your local DB using the --endpoint-url parameter

aws dynamodb list-tables --endpoint-url http://localhost:8000

You can also use dynamodb-admin to have a GUI to interact with your local database

https://www.npmjs.com/package/dynamodb-admin

Conclusion

That's it!

Don't hesitate to comment if you have any questions.

See you in the next one!

Did you find this article valuable?

Support Sonia Manoubi by becoming a sponsor. Any amount is appreciated!