"After all, the engineers only needed to refuse to fix anything, and modern industry would grind to a halt." -Michael Lewis

Enable Massive Growth

Configuring an In Memory DynamoDB instance with Java for Integration Testing

Oct 2020

While using the AWS SDK 2.0, which has support for reactive programming, it became clear that there was no straightforward support for an embedded dynamo db instance for testing. I spent a fair amount of time figuring it out by starting with this github link and ultimately adapting it to my own needs.

I'm going to work off of a template that I used in a previous blog post, here is the source code on Github.

Configuring an embedded Dynamo instance

To start, to make it "cross platform" you'll need to do some funky things in your pom file. First, ensure that you're pointing to the correct maven instance by adding the dynamo repository:

            <name>AWS DynamoDB Local Release Repository</name>

The actual dependencies you'll need seem to be basically these two:


And now is where things might get a little weird. We need to pass in a system property variable for sqlite, which embedded dynamo is using under the hood, and add a dynamo package to the manifest. So first you'll add two plugin configs:


Then some plugin management config:


Now, on my machine, which is running linux mint, i was able to get this code to run and pass:

public class PhoneServiceTest {

    private static DynamoDBProxyServer dynamoProxy;

    private static int port;

    private static int getFreePort() {
        try {
            ServerSocket socket = new ServerSocket(0);
            int port = socket.getLocalPort();
            return port;
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);

    public static void setupDynamo() {
        port = getFreePort();
        try {
            dynamoProxy = ServerRunner.createServerFromCommandLineArgs(new String[]{
        } catch (Exception e) {
            throw new RuntimeException();

    public static void teardownDynamo() {
        try {
        } catch (Exception e) {
            throw new RuntimeException();
    public void testStuff() throws Exception {
        DynamoDbAsyncClient client = DynamoDbAsyncClient.builder()
                .endpointOverride(URI.create("http://localhost:" + port))
                        AwsBasicCredentials.create("FAKE", "FAKE")))

        ListTablesResponse listTablesResponse = client.listTables().get();



        ListTablesResponse listTablesResponseAfterCreation = client.listTables().get();


As seems pretty obvious here, we're starting up dynamo before we run our test, we are creating a tale with a hash and range key named Phones, then we are verifying that the table was created by listing all the tables [there should be one table after we create it, somewhat obviously]. This test passes for me and is good enough to get started with.

You might want to take that example demonstrating it in github if you're having trouble getting this to work on your OS, since this solution doesn't seem to have the abstractions setup just yet. Otherwise, I am at least happy this appears to be working for now on my box.

Nick Fisher is a software engineer in the Pacific Northwest. He focuses on building highly scalable and maintainable backend systems.