18

If you want to write code to use AWS DynamoDB, is there any way to have it run on your local development environment? Or do you have to use the actual product?

Do you have to provision a development environment on AWS? Isn't that annoying because you'd have to work with vim and not have access to your favorite IDE? Or you have to push code to it every time you want to see if what you wrote is working?

Yasser1984
  • 2,401
  • 4
  • 32
  • 55

8 Answers8

20

Yep - you can now.

http://aws.typepad.com/aws/2013/09/dynamodb-local-for-desktop-development.html http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.html

Caveats include:

  • DynamoDB Local ignores your provisioned throughput settings
  • DynamoDB Local does not have a durability or availability SLA and is not recommended for production use
snarkyboojum
  • 324
  • 2
  • 3
  • This is huge news for my organization, but we are using Boto which unfortunately, does not support connecting to the local instance. Hopefully they will implement it soon. http://goo.gl/VPXgEU – feathj Sep 18 '13 at 01:36
  • It's super buggy, just to warn people. – The Internet Dec 08 '14 at 19:00
  • https://github.com/amazon-archives/dynamodb-janusgraph-storage-backend `This repository has been archived by the owner. It is now read-only.` – Maria Ines Parnisari Mar 09 '22 at 18:15
3

Yes, you can run it, and I'd recommend to use jcabi-dynamodb-maven-plugin to automate this process (if you're using Apache Maven).

Look at this post: http://www.yegor256.com/2014/05/01/dynamodb-local-maven-plugin.html

yegor256
  • 102,010
  • 123
  • 446
  • 597
3

On MacOS you can install and run it as a background service using brew:

Download Brew if you don't have it:

Brew is a package manager for MacOS

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

Install DynamoDB Local using Brew:

brew install dynamodb-local

Run DynamoDB as a local service:

This will ensure DynamoDB local starts up when you reboot your machine.

brew services start dynamodb-local

Run DynamoDB Local as a one-time startup:

This method will run DynamoDB local one time. You will need to re-run this upon restart.

/usr/local/bin/dynamodb-local

Then you can hit dynamoDB in a shell from your browser:

http://localhost:8000/shell/

You can interact with your DynamoDB using Javascript.

DynamoDB Javascript shell in browser

View this article for a more detailed explanation of Running a AWS DynamoDB instance locally

anataliocs
  • 10,427
  • 6
  • 56
  • 72
2

There is a lightweight version of DynamoDB which can be run locally, see:

https://aws.amazon.com/blogs/aws/dynamodb-local-for-desktop-development/

I found it a bit of a pain to remember all of the setup steps, so also created a Docker Image which wraps it, meaning you can also run DynamoDB Local with this command:

# Run DynamoDB
docker run -p 8000:8000 dwmkerr/dynamodb

# Open the shell to show it's working!
open http://localhost:8000/shell

The Docker image is available at:

https://hub.docker.com/r/dwmkerr/dynamodb/

Dave Kerr
  • 5,117
  • 2
  • 29
  • 31
1

DynamoDB Local has several production-parity flaws, there is an alternative open source local implementation that tries to match the live API more called 'dynalite' available at https://github.com/mhart/dynalite .

Adam Johnson
  • 471
  • 1
  • 5
  • 11
  • Hi if you have used dynalite , can you tell me how can I create a new table on dynalite. – Somil Nov 26 '15 at 07:16
1

If you can pull from a Maven repository and are using a JVM based language, you can now run it in the same process:

<!--Dependency:-->
<dependencies>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>DynamoDBLocal</artifactId>
        <version>1.10.5.1</version>
    </dependency>
</dependencies>
<!--Custom repository:-->
<repositories>
    <repository>
        <id>dynamodb-local</id>
        <name>DynamoDB Local Release Repository</name>
        <url>http://dynamodb-local.s3-website-us-west-2.amazonaws.com/release</url>
    </repository>
</repositories>

And here is an example taken from the awslabs/aws-dynamodb-examples Github repository:

AmazonDynamoDB dynamodb = null;
try {
    // Create an in-memory and in-process instance of DynamoDB Local that skips HTTP
    dynamodb = DynamoDBEmbedded.create();
    // use the DynamoDB API with DynamoDBEmbedded
    listTables(dynamodb.listTables(), "DynamoDB Embedded");
} finally {
    // Shutdown the thread pools in DynamoDB Local / Embedded
    if(dynamodb != null) {
        dynamodb.shutdown();
    }
}

// Create an in-memory and in-process instance of DynamoDB Local that runs over HTTP
final String[] localArgs = { "-inMemory" };
DynamoDBProxyServer server = null;
try {
    server = ServerRunner.createServerFromCommandLineArgs(localArgs);
    server.start();
    dynamodb = new AmazonDynamoDBClient();
    dynamodb.setEndpoint("http://localhost:8000");

    // use the DynamoDB API over HTTP
    listTables(dynamodb.listTables(), "DynamoDB Local over HTTP");
} finally {
    // Stop the DynamoDB Local endpoint
    if(server != null) {
        server.stop();
    }
}
mkobit
  • 43,979
  • 12
  • 156
  • 150
1

In August 2018 Amazon announced new Docker image with Amazon DynamoDB Local onboard. It does not require downloading and running any JARs as well as adding using third-party OS-specific binaries.

It is as simple as starting a Docker container:

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

You can do that manually for local development, as described above, or use it in your CI pipeline. Many CI services provide an ability to start additional containers during the pipeline that can provide dependencies for your tests.

madhead
  • 31,729
  • 16
  • 153
  • 201
-1

There are certainly ways of testing your code without actually using DynamoDB.

I personally use Mockito mocks to mock responses from the service in my unit test.

If you want a 'local' server for experimentation purposes beyond unit tests there are some open source implementations maintained by the community, for instance Alternator for Java AWS lists a few here:

prestomation
  • 7,225
  • 3
  • 39
  • 37