Create local DynamoDB Service

Need to create a local DynamoDB service within Ubuntu on Windows Subsystem for Linux 2

Setup the latest Java Runtime Environment for your distribution

  1. java -version
Command 'java' not found, but can be installed with:
sudo apt install openjdk-11-jre-headless  # version, or
sudo apt install default-jre              # version 2:1.11-72build2
sudo apt install openjdk-17-jre-headless  # version
sudo apt install openjdk-18-jre-headless  # version 18.0.2+9-2~22.04
sudo apt install openjdk-19-jre-headless  # version 19.0.2+7-0ubuntu3~22.04
sudo apt install openjdk-8-jre-headless   # version 8u382-ga-1~22.04.1
  1. Install the latest JRE sudo apt install openjdk-19-jre-headless

Download the DynamoDB jar

  • Choose the local option on this link

Extract and copy the contents to the following folder

sudo tar -xvzf dynamodb_local_latest.tar.gz -C /usr/lib/dynamodb

Create a Systemd service file for DynamoDb

  • Go to the directory /lib/systemd/system
  • Create a new file dynamodb.service
  • Paste these contents into it
Description=Dynamo DB Local Service
# The configuration file should be here:
#change this to your workspace
#path to executable.
#executable is a bash script which calls jar file
  • Create a dynamo run file in the /usr/lib/dynamodb folder to match the above config
  • Go to folder /usr/lib/dynamodb
  • Create a new run file like this sudo nano dynamodb
  • Paste this into file
sudo java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
  • Make it runnable sudo chmod 755 dynamodb
  • Go to the directory /etc/systemd/system
  • Create a symbolic link like so ln -s /lib/systemd/system/dynamodb.service dynamo.service (optional step)
  • Test the service works sudo systemctl start dynamodb
  • Enable the service to (includes autostart defined in systemd file above) sudo systemctl enable dynamodb