avatar

Andres Jaimes

How to Set Up DynamoDB for Local Development

By Andres Jaimes

In this article we are going to set up dynamodb on our local development environment. A short description of a couple of easy-to-use management tools is included.

DynamoDB

Start by downloading the DynamoDB development version. Uncompress the file and create a launch script with the following contents:

#!/bin/sh

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 8000

The script will launch dynamo on port 8000 and will create a file called shared-local-instance.db on the current directory when the first table is added. Add execution permissions to the script we just created:

$ chmod +x run.sh

And run it:

$ ./run.sh
Initializing DynamoDB Local with the following configuration:
Port: 8000
InMemory: false
DbPath: null
SharedDb: true
shouldDelayTransientStatuses: false
CorsParams: *

Done. DynamoDB is up and waiting for connections.

Run the following command to find out more about the different parameters supported by DynamoDB:

$ java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -help

See Deploying DynamoDB Locally on Your Computer for more details.

Option 1 - Set up dynamodb-manager

dynamodb-manager is my favorite way to interact with dynamo. It runs using docker, so make sure it is running on your local computer.

We are going to create a launch script called run-ui.sh with the following contents:

#!/bin/sh

docker pull taydy/dynamodb-manager
docker run -t -p 8080:80 taydy/dynamodb-manager

Add execution permissions to the script:

$ chmod +x run-ui.sh

And run it:

$ ./run-ui.sh
Using default tag: latest
latest: Pulling from taydy/dynamodb-manager
Digest: sha256:427a622d123d35c7a2aa56b7456cb0b8e2f5d789ca31bc9cabcdefg
Status: Image is up to date for taydy/dynamodb-manager:latest
docker.io/taydy/dynamodb-manager:latest

Open a web browser and go to:

http://localhost:8080

Create a new configuration to connect to our local dynamo. We can use any random keys like fakekey and fakesecret:

Create a new dynamodb configuration

Done. Use the menu to the left to see the database tables.

See dynamodb-manager on github for more details.

Option 2 - DB Browser for SQLite

If we do not have docker and do not want to install it, we can download DB Browser for SQLite. Start the application and open the database file created by dynamo: shared-local-instance.db.

Note: in order to use this tool we have to add a table for the file shared-local-instance.db to be created. Tables can be added via code, dynamodb-manager or the aws command line interface.

Happy coding