Dynamodb Java Sdk V2

Working with DynamoDB using the AWS SDK v2 for Java including the Enhanced Client
Alternatives To Dynamodb Java Sdk V2
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Awesome Aws11,283
13 days ago1December 21, 201563otherPython
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Aws Sdk Go8,2245,1008,51213 hours ago1,641September 23, 202265apache-2.0Go
AWS SDK for the Go programming language.
Boto37,96411,5454,680a day ago1,140July 06, 2022149apache-2.0Python
AWS SDK for Python
Aws Sdk Js7,33035,30613,7022 days ago1,470September 23, 2022173apache-2.0JavaScript
AWS SDK for JavaScript in the browser and Node.js
Aws Doc Sdk Examples7,277
14 hours ago99April 23, 2021255apache-2.0Java
Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.
Aws Sdk Php5,7876,7351,470a day ago1,544September 23, 202249apache-2.0PHP
Official repository of the AWS SDK for PHP (@awsforphp)
Aws Sdk Java3,9162622a day ago933May 04, 2022139apache-2.0
The official AWS SDK for Java.
Aws Sdk Ruby3,43320,4621,47616 hours ago1,207September 01, 202123apache-2.0Ruby
The official AWS SDK for Ruby.
Rusoto2,5951644043 months ago26April 25, 2022255mitRust
AWS SDK for Rust
Aws Sdk Js V32,23642714 hours ago156September 27, 2022327apache-2.0TypeScript
Modularized AWS SDK for JavaScript.
Alternatives To Dynamodb Java Sdk V2
Select To Compare


Alternative Project Comparisons
Readme

AWS SDK v2 DynamoDB including Enhanced Client

A repo demonstrating common patterns and use cases for DynamoDB using the AWS SDK v2 for java, including the Enhanced Client.

The various Java SDKs for DynamoDB are enumerated here: https://www.davidagood.com/dynamodb-java-basics/

Prerequisites

  • Have Java installed; This has been tested with Java 11 but may work with other versions

Connecting to DynamoDB

DynamoDB Local or LocalStack

See Connect to Local DynamoDB under Features.

Connect to Live AWS DynamoDB

  • Have an AWS account
  • Have the AWS CLI installed and configured

If the environment variable DYNAMODB_LOCAL_URL is not set, the default client expects to get the credentials from the default credential provider chain, same with the region.

Running The Code

You can run one of these:

  • src/main/java/com/davidagood/awssdkv2/dynamodb/App.java
  • src/main/java/com/davidagood/awssdkv2/dynamodb/AppBasic.java

Blog Posts Referencing This Repo

Features

Repository Layer Isolation

See here: DynamoDB Repository Layer Isolation in Java

Integration Testing with DynamoDB Local

See all the tests ending in "IT", for example: src/test/java/com/davidagood/awssdkv2/dynamodb/repository/DynamoDbIT.java

Some ideas are taken from the AWS SDK: here.

Enhanced Client using Static Schema

Build table schema manually, as opposed to using annotations. See here: com.davidagood.awssdkv2.dynamodb.repository.StaticSchemaImmutableItem

This is described in the official docs here.

Create Table If Not Exists

If the table does not exist, it is created at application startup time.

See com.davidagood.awssdkv2.dynamodb.repository.DynamoDbRepository.createTableIfNotExists

Connect to Local DynamoDB

If you have Docker installed you can use DynamoDB Local or LocalStack to start a locally running DynamoDB.

To override the DynamoDB client to connect to the local instance, set the enviroment variable DYNAMODB_LOCAL_URL.

For example, here's the one-liner to run DynamoDB Local:

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

Once this is running you can run the example code with the environment variable DYNAMODB_LOCAL_URL=http://localhost:8000.

See com.davidagood.awssdkv2.dynamodb.App.buildDynamoDbClient

Immutable Value Classes Using @DynamoDbImmutable

See com.davidagood.awssdkv2.dynamodb.repository.ImmutableBeanItem.

TODO

Entities

  • Regular
  • Immutable with Lombok
  • Immutable without Lombok
  • Encapsulated with MapStruct (DynamoDb Immutables not even necessary then?)

Point AWS CLI to DynamoDB Local

It may be occasionally useful to use the AWS CLI for troubleshooting while using DynamoDB Local. Here's an example of how to do that:

AWS_ACCESS_KEY_ID=dummy AWS_SECRET_ACCESS_KEY=dummy aws dynamodb list-tables --endpoint-url http://localhost:8000

Popular Sdk Projects
Popular Amazon Web Services Projects
Popular Libraries Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Java
Aws
Sdk
Schema
Dynamodb
Immutable
Lombok
Aws Sdk