This repository contains sample Aws DynamoDB CRUD application with Spring Webflux and TestContainers integration.
- Reactive API using Spring Webflux.
- AWS SDK for Java 2.x.
- Integration tests for DynamoDB using Testcontainers.
- Docker-compose file with dynamoDB, dynamodb-admin and AWS cli.
- Java 11
- Docker
-
Build docker image.
./gradlew bootBuildImage
-
Start docker-compose demo.
docker-compose -f docker/docker-compose.yml -f docker/docker-compose.app.yml up -d
-
List containers and check if all are
Up
.docker-compose -f docker/docker-compose.yml -f docker/docker-compose.app.yml ps # Name Command State Ports # ----------------------------------------------------------------------------------- # app /cnb/process/web Up 0.0.0.0:8080->8080/tcp # awscli aws dynamodb create-table ... Exit 255 # dynamodb java -jar DynamoDBLocal.ja ... Up 0.0.0.0:8000->8000/tcp # dynamodb-admin node bin/dynamodb-admin.js Up 0.0.0.0:8001->8001/tcp
-
Verify if 'users' table was successfully created. Use either
curl -X GET --location "http://localhost:8080/users"
or open your web browser and go to dynamo dashboard page. -
Test other CRUD endpoints using curl e.g.:
# Create new user: curl --header "Content-Type: application/json" \ --request POST \ --data '{"email":"curl_user@test.com"}' \ http://localhost:8080/users
-
Stop docker-compose demo.
docker-compose -f docker/docker-compose.yml -f docker/docker-compose.app.yml down -v
- Getting Started with Java and DynamoDB
- Testcontainers
- Installing, updating, and uninstalling the AWS CLI version 2 on macOS
- Working with Global Secondary Indexes: Java
- Design a Database for a Mobile App
- How to model one-to-many relationships in DynamoDB
Distributed under the MIT License. See LICENSE
for more information.