https://github.com/rbiedrawa/spring-webflux-aws-dynamodb
This repository contains sample Amazon DynamoDB CRUD application with Spring Webflux and TestContainers integration.
https://github.com/rbiedrawa/spring-webflux-aws-dynamodb
amazon aws aws-sdk-java-v2 docker docker-compose dynamodb dynamodb-local gradle reactive reactive-programming spring-boot spring-webflux testcontainers
Last synced: 3 months ago
JSON representation
This repository contains sample Amazon DynamoDB CRUD application with Spring Webflux and TestContainers integration.
- Host: GitHub
- URL: https://github.com/rbiedrawa/spring-webflux-aws-dynamodb
- Owner: rbiedrawa
- License: mit
- Created: 2021-04-27T16:19:26.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-31T02:06:59.000Z (over 3 years ago)
- Last Synced: 2025-01-26T18:17:20.418Z (5 months ago)
- Topics: amazon, aws, aws-sdk-java-v2, docker, docker-compose, dynamodb, dynamodb-local, gradle, reactive, reactive-programming, spring-boot, spring-webflux, testcontainers
- Language: Java
- Homepage:
- Size: 72.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Webflux CRUD application (Amazon DynamoDB)
This repository contains sample Aws DynamoDB CRUD application with Spring Webflux and TestContainers integration.
## Features
* Reactive API using Spring Webflux.
* [AWS SDK for Java 2.x.](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/home.html)
* Integration tests for DynamoDB using Testcontainers.
* Docker-compose file with [dynamoDB](https://hub.docker.com/r/amazon/dynamodb-local/), [dynamodb-admin](https://hub.docker.com/r/aaronshaf/dynamodb-admin) and [AWS cli](https://hub.docker.com/r/banst/awscli).## Getting Started
### Prerequisites
* Java 11
* Docker### Usage
* Build docker image.
```shell
./gradlew bootBuildImage
```* Start docker-compose demo.
```shell
docker-compose -f docker/docker-compose.yml -f docker/docker-compose.app.yml up -d
```* List containers and check if all are `Up`.
```shell
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](http://localhost:8001/tables/users).* Test other CRUD endpoints using curl e.g.:
```shell
# Create new user:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"email":"[email protected]"}' \
http://localhost:8080/users
```* Stop docker-compose demo.
```shell
docker-compose -f docker/docker-compose.yml -f docker/docker-compose.app.yml down -v
```## References
* [Getting Started with Java and DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Java.html)
* [Testcontainers](https://www.testcontainers.org/)
* [Installing, updating, and uninstalling the AWS CLI version 2 on macOS](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html)## Additional Links
* [Working with Global Secondary Indexes: Java](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSIJavaDocumentAPI.html)
* [Design a Database for a Mobile App](https://aws.amazon.com/getting-started/hands-on/design-a-database-for-a-mobile-app-with-dynamodb/)
* [How to model one-to-many relationships in DynamoDB](https://www.alexdebrie.com/posts/dynamodb-one-to-many/)## License
Distributed under the MIT License. See `LICENSE` for more information.