- Authentication with JWT
- Unit & Integration Tests
- Deploying Spring Boot App to AWS Fargate via CDK
- CDK is being used to create a CloudFormation Template.
- Go to
dolap.tsinsidecdk/bin, seeaccountandregionbase options. Secretsreferenced indolap-stack.tsinsidecdk/lib, will be given by Secrets of the repository.- To be able to deploy via GitHub Actions, you also need to set your
AWS Secrets. - Create an
IAM Userwithadministratorprivileges. I haven't found an util to create a IAM privileges template depending on services you deploy via CDK. - Therefore, It might best to try with a free tier account instead a real product acc at first.
- Put your
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_ACCOUNTcredentials toSecretsin settings in your repo. DO NOT FORGET TO SET YOUR SECRETS IN SECRETS SETTINGS OF THE REPOIf you aim to deploy via CDK to AWS via GitHub Actions.- I did not configure NAT Gateway to avoid extra bills as this is an open source thing.
- If you have security concerns with your app or it's real app, do not forget to put your stack behind a NAT Gateway in VPC Settings.
- Go to
application.propertiesfile in spring boot app and fill it with your credentials.
- Navigate into dolap folder and then, find create .env file.
- Fill your secrets, have a look at
application.propertiesit'll give you info about how to reference the secrets. - Run
export $(cat .env | xargs)and then, runmvn spring-boot:run. - Optionally, you can run
SPRING_DATABASE_URL=url other-secrets mvn spring:boot run. - If you fill the credentials which work, your app should start successfully.
- The connection is tested with AWS RDS so, you can use it confidently.
- mvn test
docker build -t dolap .docker run -p 8080:8080 -e SPRING_DATASOURCE_URL=jdbc:postgresql://AWS-RDS-URL:5432/postgres -e SPRING_DATASOURCE_USERNAME=postgres -e SPRING_DATASOURCE_PASSWORD=password dolap- Note: We'll pass secrets in CI when we deploy, see above.
- /health - Health Check API for AWS ALB see CDK Stack for detailed info.
- /auth/signup - POST - Sign Up
- /auth/login - POST - Sign In / Login
- Requests below require Authorization Header: Bearer JWT
- /categories - GET - Lists categories
- /categories - POST - Add new category with given name
- /categories/id - GET - Finds category for given id.
- /categories/id - PUT - Updates category for given id.
- /categories/id - DELETE - Deletes category for given id.
- /categories/id/products - Lists products for given category id.
- Requests below require Authorization Header: Bearer JWT
- /products - POST - Add new product with given name, price, category_id
- /products/id - GET - Finds product for given id.
- /products/id - PUT - Updates product for given id.
- /products/id - DELETE - Deletes product for given id.