1- # Explore ways to run Spring Boot application with AWS Lambda Java or Customer Runtime with GraalVM Native Image
1+ # Explore ways to run Serverless application on AWS Lambda with Java 21 based Docker Container Image
22
33## Architecture
44
99## Project Description
1010The code example include storing and retrieving product from the Amazon DynamoDB. I put Amazon API Gateway in front of my Lambdas.
1111
12- I explore the following ways to run Spring Boot application with AWS Lambda Java or Customer Runtime with GraalVM Native Image:
13-
14- - Lambda with Java 21 Runtime and Spring Boot 3.2 and aws-serverless-java-container
15- - Lambda with Java 21 Runtime and Spring Boot 3.2 and Spring Cloud Function
16- - Lambda with Java 21 Runtime and Spring Boot 3.2 and Lambda Web Adapter
17- - Lambda with Custom Runtime and Spring Boot 3.2 and GraalVM Native Image
1812
1913
2014I made all the test for the following use cases:
@@ -27,28 +21,45 @@ I made all the test for the following use cases:
2721
2822# Installation and deployment
2923
24+ Install Java Coretto 21 (https://docs.aws.amazon.com/corretto/latest/corretto-21-ug/amazon-linux-install.html
25+
26+ sudo yum install java-21-amazon-corretto
27+
28+ Install Maven
29+
30+ wget https://mirrors.estointernet.in/apache/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz
31+ tar -xvf apache-maven-3.8.5-bin.tar.gz
32+ sudo mv apache-maven-3.8.5 /opt/
33+
34+
35+ M2_HOME='/opt/apache-maven-3.8.5'
36+ PATH="$M2_HOME/bin:$PATH"
37+ export PATH
38+
39+
40+
41+
3042``` bash
3143
3244Clone git repository locally
33- git clone https://github.com/Vadym79/AWSLambdaJavaWithSpringBoot .git
45+ git clone https://github.com/Vadym79/AWSLambdaJavaDockerImage .git
3446
3547Compile and package the Java application with Maven from the root (where pom.xml is located) of the project
36- mvn clean package
48+ mvn compile dependency:copy-dependencies -DincludeScope=runtime
3749
38- Deploy your application with AWS SAM
39- sam deploy -g
40- ```
50+ docker build -t aws-pure-lambda-java21-custom-docker-image:v1 .
51+ docker save aws-pure-lambda-java21-custom-docker-image > aws-pure-lambda-java21-custom-docker-image
4152
42- In order not to use AWS Lambda SnapStart comment both lines in the globals's section of the Lambda function.
53+ aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin {aws_account_id}.dkr.ecr.eu-central-1.amazonaws.com
4354
44- Globals:
45- Function:
46- #SnapStart:
47- #ApplyOn: PublishedVersions
55+ aws ecr create-repository --repository-name aws-pure-lambda-java21-custom-docker-image --image-scanning-configuration scanOnPush=true --region eu-central-1
4856
49- In order to user AWS Lambda SnapStart uncomment both lines above. For different Priming optimizations enabling of SnapStart is required.
50- SnapStart doesn't currently work for AWS Custom Runtimes, so for GraalVM Native Image.
57+ docker tag aws-pure-lambda-java21-custom-docker-image:v1 265634257610.dkr.ecr.eu-central-1.amazonaws.com/aws-pure-lambda-java21-custom-docker-image:v1
5158
59+ docker push 265634257610.dkr.ecr.eu-central-1.amazonaws.com/aws-pure-lambda-java21-custom-docker-image:v1
60+ Deploy your application with AWS SAM
61+ sam deploy --image-repository=${ecr_image_reposiory} -g
62+ ```
5263
5364## Further Readings
5465
0 commit comments