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:

1#!/bin/sh
2
3java -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:

1$ chmod +x run.sh

And run it:

1$ ./run.sh
2Initializing DynamoDB Local with the following configuration:
3Port: 8000
4InMemory: false
5DbPath: null
6SharedDb: true
7shouldDelayTransientStatuses: false
8CorsParams: *

Done. DynamoDB is up and waiting for connections.

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

1$ 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:

1#!/bin/sh
2
3docker pull taydy/dynamodb-manager
4docker run -t -p 8080:80 taydy/dynamodb-manager

Add execution permissions to the script:

1$ chmod +x run-ui.sh

And run it:

1$ ./run-ui.sh
2Using default tag: latest
3latest: Pulling from taydy/dynamodb-manager
4Digest: sha256:427a622d123d35c7a2aa56b7456cb0b8e2f5d789ca31bc9cabcdefg
5Status: Image is up to date for taydy/dynamodb-manager:latest
6docker.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