The purpose of this repository is to learn about DynamoDB. So if some things seems to be overthing then they are overthought so that I could gain knowledge.
Before running Docker containers both Spring Boot Apps need to be build. The Front App provides model library for the Backend App so it needs to be build first.
mvn clean install -f ./front/pom.xml
mvn clean install -f ./backend/pom.xml
docker-compose up --build
Or as one huge command:
docker-compose down && mvn clean install -f ./front/pom.xml && mvn clean install -f ./backend/pom.xml && docker-compose up --build
This is a very fast command where Maven skips quality checks and uses multicores:
docker-compose down && mvn clean install -f ./front/pom.xml -Pno-quality -T4 && mvn clean install -f ./backend/pom.xml -Pno-quality -T4 && docker-compose up --build
- Both Spring Boot Apps have a Maven profile
no-quality
defined which skips some quality checks. - Maven can run on multiple threads be providing
-T
parameter.
mvn clean install -T4 -f ./front/pom.xml -Pno-quality && mvn clean install -T4 -f ./backend/pom.xml -Pno-quality
To access DynamoDB tables and documents use DynamoDB Admin web tool.
For Backend App it is required to provide the same credencials as defined in docker-compose
file. Otherwise tables in DynamoDB won't be shown.
On default 15672 port a RabbitMQ Management is available. User is cookieMq
and password is very_secret_cookie_password
.
In case when either or both Spring Boot Apps cannot connect to RsbbitMQ, check out if there is avaliable space (e.g. egzamin how much space is taken by all images in Docker Desktop). If that doesn't help then execute these two commands to free up some space for RabbitMQ Container:
docker system prune
docker volume rm $(docker volume ls -qf dangling=true)
This app produces messages that are pushed into RabbitMQ queue. This app does not have a direct access into DynamoDB. It requires to use Backend App to interact with DynamoDB. To use this app check out the Swagger documentation.
It is possible to run this Front App locally (e.g. for debugging purposes) and use other Docker containers. To do so, run this App with local
Spring profile and comment out respected container in docker-compose
file.
This app consumes messages from a RabbitMQ Queue and stores data in DynamoDB. A Swagger documentation is avaliable along with a Postman collection.
Just like with the Front All it is possible to run this Backend App locally (e.g. for debugging purposes) and use other Docker containers. To do so, run this App with local
Spring profile and comment out respected container in docker-compose
file.
This container's purpose is to run a shell sccript and then it's stopped. The shell script contains few Curl commands to insert (send POST request) few movies into DynamoDB table via Front App endpoint.
- Front App Swagger
- Backend App Swagger
- DynamoDB Admin
- RabbitMQ Management
- user
cookieMq
- password
very_secret_cookie_password
- user
This container runs specific commands, so after the DynamoDB container is running you can play with AWS CLI container.
See AWS Reference documentation for more details.
To get an AWS CLI container run docker pull amazon/aws-cli:latest
command.
- List all tables in DynamoDB
docker run --rm -it --network=host -e AWS_SECRET_ACCESS_KEY=very_secret_aws_key -e AWS_ACCESS_KEY_ID=very_secret_aws_access_key -e AWS_DEFAULT_REGION=local amazon/aws-cli dynamodb list-tables --endpoint-url=http://localhost:8000/
- List items in a
mcu_movies
table:docker run --rm -it --network=host -e AWS_SECRET_ACCESS_KEY=very_secret_aws_key -e AWS_ACCESS_KEY_ID=very_secret_aws_access_key -e AWS_DEFAULT_REGION=local amazon/aws-cli dynamodb scan --table-name mcu_movies --endpoint-url=http://localhost:8000/
- Put one item into a
mcu_movies
table:A result of this command can be easly viewed in a DynamoDB Admin Web UI.docker run --rm -it --network=host -e AWS_SECRET_ACCESS_KEY=very_secret_aws_key -e AWS_ACCESS_KEY_ID=very_secret_aws_access_key -e AWS_DEFAULT_REGION=local amazon/aws-cli dynamodb put-item --table-name mcu_movies --item '{"title": {"S": "Black Widow"}, "release_year": {"N": "2021"}, "created_at": {"S": "by aws cli"}}' --endpoint-url=http://localhost:8000/