Local DynamoDB in WSL2

  • Install latest AWS Command Line Interface
  • Install Ubuntu
  • Download the local DynamoDB jar
  • Unzip the file to a folder like C:\dynamodb or if you are already in Ubuntu WSL2 /mnt/c/dynamodb
  • Check your java version.  Looks like I'm good to go.  I used this to get a modern compatible version
robin@wasp:/mnt/c/dynamodb $ java --version
openjdk 11.0.14.1 2022-02-08
OpenJDK Runtime Environment (build 11.0.14.1+1-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.14.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

Now run the local DynamoDB in headless mode

nohup java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb >/dev/null 2>&1 & I'm using the sharedDb option to keep the data persistent on disk

Connect to the default port 8000 and list tables aws dynamodb list-tables --endpoint-url http://localhost:8000

It works

C:\Users\siliconrob>aws dynamodb list-tables --endpoint-url http://localhost:8000
{
    "TableNames": [
        "DEV_CalendarSyncEvent",
        "DEV_ChannelSyncEvent",
        "DEV_ChannelWebhookQueue",
        "DEV_Error",
        "DEV_OutboundWebhookQueue"
    ]
}

Download the NoSQL Workbench for more exploration

If you want to have the service start on Windows startup add a shortcut to the folder: Win + R + shell:startup

Have it call the wsl.exe as root to start the service without prompting, C:\Windows\System32\wsl.exe -u root <cmd from above>

Or you could run it as as docker container