- Newest
- Most votes
- Most comments
Here are the dependencies you may need to include in your Java base image to support Spring Cloud and AWS Lambda:
Java runtime environment (JRE): This should be included in your Java base image. You can use OpenJDK or Oracle JDK as the JRE.
AWS Lambda Java runtime interface: This is provided by the AWS Lambda Java SDK, which you can include as a dependency in your deployment package.
Spring Cloud AWS dependencies: These include the Spring Cloud AWS Core and Spring Cloud AWS Context modules, which provide integration with AWS services such as S3, DynamoDB, and SQS. You can include these dependencies in your deployment package using Maven or Gradle.
Spring Boot dependencies: Depending on your use case, you may also need to include Spring Boot dependencies in your deployment package. However, since Spring Boot does not yet officially support Java 17, you may need to use an older version of Spring Boot that supports Java 16 or earlier.
Here's an example Dockerfile that uses a lightweight Java 17 base image and includes the necessary dependencies:
FROM adoptopenjdk:17-jre-hotspot
RUN mkdir -p /opt/app
WORKDIR /opt/app
# Copy the deployment package into the container
COPY target/my-lambda-function.jar /opt/app
# Install the AWS Lambda Java runtime interface
RUN curl -sL https://repo1.maven.org/maven2/com/amazonaws/aws-lambda-java-core/1.2.1/aws-lambda-java-core-1.2.1.jar -o /opt/app/aws-lambda-java-core.jar
# Install the Spring Cloud AWS dependencies
RUN curl -sL https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-aws-core/2.3.2/spring-cloud-aws-core-2.3.2.jar -o /opt/app/spring-cloud-aws-core.jar && \
curl -sL https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-aws-context/2.3.2/spring-cloud-aws-context-2.3.2.jar -o /opt/app/spring-cloud-aws-context.jar
CMD ["java", "-jar", "/opt/app/my-lambda-function.jar"]
Relevant content
- asked a year ago
- asked a year ago
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
Does this help? https://aws.amazon.com/blogs/compute/build-a-custom-java-runtime-for-aws-lambda/