Developing Locally Against AWS-Hosted DynamoDB

Developing Locally Against AWS-Hosted DynamoDB, Part 2

In my previous post, we got our code running locally and connecting to DynamoDB in the cloud. Now we are going to get our code connecting to DynamoDB also running locally.

Why would we want to do this? Well, it gives us a great development experience. Each developer can have their own instance of DynamoDB running and not have to worry about other developers messing with them. Sometimes it’s nice to not have to share with anyone.

To accomplish this, we will run DynamoDB in a Docker container on the ground. Docker is a technology that allows the distribution of software pieces in a more rigid environment. Think of Docker almost like a good way to distribute VMs, but the VMs are lighter weight; VMs on a diet.

With Docker, the VMs templates are called images. And when the images are running, they are called containers.

You are going to need to install Docker and then download the Docker image for DynamoDB.

docker pull amazon/dynamodb-local

Start the Docker image.

docker run -p 8000:8000 amazon/dynamodb-local

You should now have a running container for DynamoDB, but we don’t have a GUI to administer it. We can administer Docker using a built-in shell at http://localhost:8000/shell.

Next, we need to create a contact table similar to the one we created earlier.

Now let’s write a script to list the tables to make sure we got it created correctly.

Modifying our code to call a local DynamoDB is really easy. We just need to add a ServiceURL; our previous example will work.



If you have any questions or comments, hit me up on Twitter or sound off in the comments below.

Related posts