Skip to content

Different examples of solutions API Gateway->Lambda->DynamoDB with Lambda managed Java 21 runtime based on Spring Boot 3 with AWS Serverless Java Container, AWS Lambda Web Adapter, Spring Cloud Function (all including SnapStart enabling and various priming techniques), Custom Docker Image and GraalVM Native Image

Notifications You must be signed in to change notification settings

Vadym79/AWSLambdaJavaWithSpringBoot

Repository files navigation

Explore ways to run Spring Boot application with AWS Lambda Java or Customer Runtime with GraalVM Native Image

Architecture

Application Architecture

Project Description

The code example include storing and retrieving product from the Amazon DynamoDB. I put Amazon API Gateway in front of my Lambdas.

I explore the following ways to run Spring Boot application with AWS Lambda Java or Customer Runtime with GraalVM Native Image:

  • Lambda with Java 21 Runtime and Spring Boot 3.2 and aws-serverless-java-container
  • Lambda with Java 21 Runtime and Spring Boot 3.2 and Spring Cloud Function
  • Lambda with Java 21 Runtime and Spring Boot 3.2 and Lambda Web Adapter
  • Lambda with Custom Runtime and Spring Boot 3.2 and GraalVM Native Image

I made all the test for the following use cases:

  • Lambda function without SnapStart enabled
  • Lambda function with SnapStart enabled but without usage of Priming
    -- doesn't currently work for AWS Custom Runtimes, so for GraalVM Native Image
  • Lambda function with SnapStart enabled but with usage of Priming (DynamoDB request invocation and if possible proxing the whole web request)
    -- doesn't currently work for AWS Custom Runtimes, so for GraalVM Native Image

Installation and deployment

Clone git repository locally
git clone https://github.com/Vadym79/AWSLambdaJavaWithSpringBoot.git

Compile and package the Java application with Maven from the root (where pom.xml is located) of the project
mvn clean package

Deploy your application with AWS SAM
sam deploy -g  

In order not to use AWS Lambda SnapStart comment both lines in the globals's section of the Lambda function.

Globals:
Function:
#SnapStart:
#ApplyOn: PublishedVersions

In order to user AWS Lambda SnapStart uncomment both lines above. For different Priming optimizations enabling of SnapStart is required.
SnapStart doesn't currently work for AWS Custom Runtimes, so for GraalVM Native Image.

Further Readings

My article series "Spring Boot 3 application on AWS Lambda"

My article series "AWS Lambda SnapStart"

About

Different examples of solutions API Gateway->Lambda->DynamoDB with Lambda managed Java 21 runtime based on Spring Boot 3 with AWS Serverless Java Container, AWS Lambda Web Adapter, Spring Cloud Function (all including SnapStart enabling and various priming techniques), Custom Docker Image and GraalVM Native Image

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published