Skip to content

A Leiningen plugin and boot task for providing a local DynamoDB instance

License

Notifications You must be signed in to change notification settings

dmcgillen/clj-dynamodb-local

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clj-dynamodb-local Build Status

A Leiningen 2 plugin and boot task providing a local DynamoDB instance to run tests against.

This starts an instance of DynamoDB Local (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html) provided by Amazon and shuts it down once any proceeding tasks have completed. DynamoDB Local is downloaded on first run, and stored in ~/.clj-dynamodb-local.

Usage

Clojars Project

Leiningen

Add this library as a dependency to the :plugins vector of your project.clj.

You can start DynamoDB Local, followed by any other tasks you may want to run, using the following:

$ lein dynamodb-local other-tasks...

The plugin will shutdown DynamoDB Local upon completion.

DynamoDB Local can be started without running any other tasks if you so wish:

$ lein dynamodb-local

Killing the process (e.g. with Ctrl+C) will shutdown DynamoDB Local.

If run as a background process (e.g. $ lein dynamodb-local &) all child processes should be terminated upon completion (e.g. pkill -P parent-process-id). The plugin will handle the termination of the DynamoDB Local process.

Boot

Add this library as a dependency to your build.boot file.

require the boot namespace and task provided in the appropriate place in your build.boot:

'[dynamodb-local.boot :refer [dynamodb-local]]

Add the dynamodb-local boot task into your build pipeline at the appropriate point, supplying any required options, for example:

(deftask development []
  (comp (testing)
        (dynamodb-local :project {:dynamodb-local {:port 8090
                                                   :in-memory? true}})
        (repl)))

A shutdown hook will be added to shutdown DynamoDB Local when the JVM exits.

Configuration

You can set some parameters by adding the :dynamodb-local keyword to your project.clj.

:port

Set the port that you want DynamoDB Local to run on (defaults to 8000).

:dynamodb-local {:port 12345}

It is also possible to set the port by using the environment variable DYNAMODB_PORT.

:in-memory?

Set if you want DynamoDB Local to be run in memory (defaults to false).

Note: This should not be used in conjunction with the :db-path parameter. If it is, :db-path will be ignored.

:dynamodb-local {:in-memory? true}

:shared-db?

Set if you want DynamoDB Local use a shared db rather than have separate files for each region/credentials combo. See the -sharedDb switch documented here for more info.

:dynamodb-local {:shared-db? true}

:db-path

Set the path that DynamoDB Local will write its database file to (defaults to ./.clj-dynamodb-local). If a relative path is used, it will be relative to the current directory.

Note: This should not be used in conjunction with the :in-memory? parameter. If it is, :db-path will be ignored.

:dynamodb-local {:db-path "/path/to/desired/db/output/"}

:jvm-opts

Pass JVM options to the DynamoDB process. Behaves the same as the 'normal' :jvm-opts in a project.clj

:dynamodb-local {:jvm-opts ["-server" "-Xmx512m"]}

License

Copyright © 2018 Donovan McGillen

Distributed under the Eclipse Public License, the same as Clojure.

About

A Leiningen plugin and boot task for providing a local DynamoDB instance

Resources

License

Stars

Watchers

Forks

Packages

No packages published