AWS DynamoDB Connector

The AWS DynamoDB connector provides a flow for streaming DynamoDB requests. For more information about DynamoDB please visit the official documentation.

Artifacts

sbt
libraryDependencies += "com.lightbend.akka" %% "akka-stream-alpakka-dynamodb" % "0.11"
Maven
<dependency>
  <groupId>com.lightbend.akka</groupId>
  <artifactId>akka-stream-alpakka-dynamodb_2.12</artifactId>
  <version>0.11</version>
</dependency>
Gradle
dependencies {
  compile group: "com.lightbend.akka", name: "akka-stream-alpakka-dynamodb_2.12", version: "0.11"
}

Usage

This connector uses the default credential provider chain provided by the DynamoDB Java SDK to retrieve credentials.

Before you can construct the client, you need an ActorSystem, ActorMaterializer, and ExecutionContext.

Scala
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
implicit val ec = system.dispatcher
Java
final ActorSystem system = ActorSystem.create();
final ActorMaterializer materializer = ActorMaterializer.create(system);

You can then create the client with a settings object.

Scala
val settings = DynamoSettings(system)
val client = DynamoClient(settings)
Java
final DynamoSettings settings = DynamoSettings.apply(system);
final DynamoClient client = DynamoClient.create(settings, system, materializer);

We can now send requests to DynamoDB across the connection.

Scala
import DynamoImplicits._
val listTablesResult: Future[ListTablesResult] = client.single(new ListTablesRequest())
Java
final Future<ListTablesResult> listTablesResultFuture = client.listTables(new ListTablesRequest());

Running the example code

The code in this guide is part of runnable tests of this project. You are welcome to edit the code and run it in sbt.

Test code requires DynamoDB server running in the background. You can start one quickly using docker:

docker run --rm -p 8001:8000 deangiberson/aws-dynamodb-local

Scala
sbt
> dynamodb/testOnly *Spec
Java
sbt
> dynamodb/testOnly *Test
The source code for this page can be found here.