Skip to content

How to install DynamoDb on local Ubuntu Development

It is common for developers to be developing products which use and interact with several cloud-based products and services. However, developers don't necessarily want to be permanently connected to the internet or even necessarily want to incur additional costs while developing or even just taking the time to learn how to utilize all the functionality that is at their disposal.

It makes sense for developers to be able to download and install a version of the product so they can install and learn how to use the product. The primary objective for developers will too simulate a production environment to debug and test in a disconnected manner.

Although LocalStack, A fully functional local AWS cloud stack, is available and fairly easy to use. I wanted to set up an isolated DynamoDB environment so I could learn how to leverage it in a project.

What is DynamoDB

Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability.

DynamoDB lets you offload the administrative burdens of operating and scaling a distributed database so that you don't have to worry about hardware provisioning, setup and configuration, replication, software patching, or cluster scaling. Also, DynamoDB offers encryption at rest, which eliminates the operational burden and complexity involved in protecting sensitive dat.

With DynamoDB, you can create database tables that can store and retrieve any amount of data, and serve any level of request traffic. You can scale up or scale down your tables' throughput capacity without downtime or performance degradation, and use the AWS Management Console to monitor resource utilization and performance metrics.

What DynamoDB Local

DynamoDB Local is a downloadable version of DynamoDB that lets you write and test applications without accessing the DynamoDB web service, instead, it is self-contained on your computer.

When you're ready to deploy your application in production, you can make a few minor changes to the code so that it uses the DynamoDB web service.

Having this local version helps you save on provisioned throughput, data storage, and data transfer fees. In addition, you don't need an internet connection while you're developing your application.

DynamoDB local is available as a download, as an Apache Maven dependency, or as a Docker image.

How to Install DynamoDB Local on your Ubuntu Workstation

I wanted to do some development on my new System76 Darter Pro so I could develop on the move. DynamoDb Local is very easy to install and set up but I made some additional tweaks to make it even easier for myself.

The following is the set of Bash commands I use:

DynamoDB Local makes use of Java so if you don't have Java installed on your machine you will need to install Java on ubuntu desktop for development

# Create a hidden folder in your home directory
mkdir ./dynamolocal

# change into the new created directory
cd ./dynamolocal

# Download the DynamoDB tar 
# Best to do this on a fast internet connection
wget http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest.tar.gz

#Once the file is download you uncompress it
tar xzf dynamodb_local_latest.tar.gz

#Check the file contents in the folder 
ls 

# The structure should look something similar too 
DynamoDBLocal.jar  LICENSE.txt  third_party_licenses
DynamoDBLocal_lib  README.txt

# Optional once the file is uncompress delete the tar
rm -f dynamodb_local_latest.tar.gz 

We are now already to use DynamoDb locally, if you open the README.txt using nano i.e. nano README.TXT the instructions and command to start running DynanmoDB are contained within.

It is simply the case of running the following command

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

Which will respond with

Initializing DynamoDB Local with the following configuration:
Port:	8000
InMemory:	false
DbPath:	null
SharedDb:	false
shouldDelayTransientStatuses:	false
CorsParams:	*

You can now open your browser and visit ttp://localhost:8000/shell. The following will be displayed

How to create terminal shortcut for dynamodb on Ubuntu

This is great, but if you're anything like me you are going to have difficulty remembering the full command. So you'll want and need to create something that is a little easier to remember. Fortunately, one of the great things about Linux is that it provides you the flexibility to customize your commands.

open your Bash Profile using nano

nano ~/.bashrc

Then add the following function to your bashrc content.

function dynamo(){
 cd $HOME/dynamolocal
 java -Djava.library.path=./DynamoDBLocal_lib/ -jar DynamoDBLocal.jar
}

Save and exit from the file then refresh your terminal window

# You can use either source approach 
source  ~/.bashrc

# or the linux based short cut of using .
. ~/.bashrc

Now you can start the your DynamoDB local instance in the terminal window by simply

dynamo

Summary

We now have a local copy of DynamoDB installed which we can use for development purposes. We have also taken the time to create a memorable shortcut so we don't have to destroy brain cells to remember the long winded command to get DynamoDB running.

Gary Woodfine
Latest posts by Gary Woodfine (see all)