Skip to content

Lambda Native Function using Java and GraalVM, which stores EDA events on Amazon DynamoDB.

License

Notifications You must be signed in to change notification settings

aosolorzano/city-tasks-lambda-native-with-dynamodb

Repository files navigation

EDA using Spring Boot and Spring Cloud Functions to deploy native executables on ECS and Lambda respectively.

  • Author: Andres Solorzano.
  • Level: Advanced.
  • Technologies: Java 17, Spring Boot 3, Spring Cloud 4, Spring Native, Spring WebFlux, Spring OAuth2, Quartz, Flyway, Lombok, Testcontainers, LocalStack, AWS Copilot CLI, AWS SAM-CLI, Amazon Cognito, Amazon Aurora (with PostgreSQL), DynamoDB, Application Load Balancer, EventBridge, Lambda, and Docker.

You can read the following articles from my Medium.com account to get more project details:

  1. Multi-Account environment on AWS using IAM Identity Center.
  2. OAuth2 in Spring Boot Native microservice.
  3. Deploying Spring Boot Native microservice using Cross-Account deployment.
  4. End-to-End Encryption using TLS ECDSA certificate and ACM with Copilot CLI.
  5. EDA using Amazon EventBridge, Lambda, and SAM-CLI, with Fargate ECS as Event Source.
  6. Storing EDA events in DynamoDB from a Native Lambda Function using Spring Cloud Functions.

Description.

This project uses Spring Boot to manage Quartz Jobs with the help of Spring Webflux and Spring Native. The Quartz library is configured for a clustered environment, so it needs Postgres to store and manage Jobs executions. When a Quartz Job is executed, the calling method retrieves the Device item associated with the Tasks and updates its state in DynamoDB. To perform all these activities, the users must have a valid access token (JWT) to access the endpoints. All test cases use TDD from the beginning of the development, and only Integration Tests are executed with the support of Testcontainers and LocalStack to try to cover real-world scenarios. This project also uses Docker Compose to deploy a local cluster with the required services for local testing.


Prerequisites.

  • Git.
  • AWS CLI (version 2.11.+).
  • AWS Copilot CLI (version 1.27.+).
  • AWS SAM CLI (version 1.90.+).
  • OpenJDK (version 17.0.+). You can use SDKMAN.
  • Apache Maven (version 3.9.+) You can use SDKMAN.
  • Spring Boot (version 3.1.+)
  • Docker and Docker Compose.

Project Structure.

The project is divided into the following directories:

  • src: Contains source code of the required projects.
  • copilot: Contains the Copilot configuration files.
  • template.yaml: Contains the SAM configuration.
  • docker-compose.yml: Contains the Docker Compose file to deploy the local cluster.
  • pom.xml: Contains the project's dependencies.
  • utils: Contains the scripts to deploy the application locally or in AWS.

Deployment Options.

You need to execute the following command from the project's root directory:

./run-scripts.sh

The script will ask you for the required AWS profiles to deploy the application locally or in AWS:

Then, the script shows a main menu with the following options:

If you choose option 'h' for 'Helper Menu,' you can create/deploy dependent resources required before deploying the application on AWS.


Internal Documentation.

The internal project documentation is divided into the following directories:

  • utils/docs: Contains the project's documentation.
  • utils/docs/images: Contains solution's architecture images.

The markdown documentation for individual projects is available at: