Skip to content

Latest commit

 

History

History

unicorn-store

From Serverful to Serverless Java with AWS Lambda

Pre-Requisites

  1. Install AWS CDK
  2. Install AWS CLI
  3. Install jq
  4. Install artillery

Architecture overview

Throughout this workshop we are going to work with an example application named UnicornStore.

The UnicornStore is a Spring Boot Java Application that provides CRUD-Operations for Unicorn-Records. It stores them in a relational database (Postgres) and publishes and event afterwards in an eventbus (EventBridge).

Stage 01: AWS Serverless Java Container

The following diagram shows the outcome after applying the instructions of the first lab:

Unicorn Store Overview

  • (1) End-User can interact with the service via a REST-API that provides basic CRUD operations

    POST /unicorns - Create a new unicorn
    PUT /unicorns/{id} - Update an existing uncicorn
    GET /unicorns/{id} - Retrieve an existing unicorn
    DELETE /unicorns/{id} - Delete an existing unicorn

  • (2) The API Gateway proxies the request to the Lambda Function

  • (3) The application communicates with the database and the eventbus. Depending on the service this can be in the same VPC or within the AWS Network.

Stage 02: Spring Cloud functions

You will migrate your existing application to work with Spring Cloud functions and understand the differences in design and performance.

Stage 03: Alternatives

You will look at alternatives such as compile-time frameworks & an implementations without a framework to understand the implications.

Setup

The following script will build the infrastructure stack via AWS CDK.

./setup-infrastructure.sh

To deploy the different applications use:

./deploy.sh spring #(or quarkus, micronaut, spring-graalvm)

To run a load test for the Spring-App use the following script:

./benchmark.sh spring #(or quarkus, micronaut, spring-graalvm)

Security

The project uses CDK-Nag to identify issues with the environment configuration. Since this is workshop environment we are not using all the capabilities that you might need in production (E.g. Multi-AZ setup). Please refer to the CDK-Nag suppressions in the CDK-App to identify certain choices we have made for this setup.