Skip to content

Latest commit

 

History

History
61 lines (38 loc) · 3.2 KB

File metadata and controls

61 lines (38 loc) · 3.2 KB

Deploy Java Lambda functions with container images

You can deploy your Lambda function code as a container image. AWS provides the following resources to help you build a container image for your Java function:

  • AWS base images for Lambda

    These base images are preloaded with a language runtime and other components that are required to run the image on Lambda. AWS provides a Dockerfile for each of the base images to help with building your container image.

  • Open-source runtime interface clients

    If you use a community or private enterprise base image, add a runtime interface client to the base image to make it compatible with Lambda.

The workflow for a function defined as a container image includes these steps:

  1. Build your container image using the resources listed in this topic.

  2. Upload the image to your Amazon ECR container registry. See steps 7-9 in Create image.

  3. Create the Lambda function and deploy the image.

AWS base images for Java

AWS provides the following base images for Java:

Tags Runtime Operating system Dockerfile
11 Java 11 (Corretto) Amazon Linux 2 Dockerfile for Java 11 on GitHub
8.al2 Java 8 (Corretto) Amazon Linux 2 Dockerfile for Java 8.al2 on GitHub
8 Java 8 (OpenJDK) Amazon Linux 2018.03 Dockerfile for Java 8 on GitHub

Docker Hub repository: amazon/aws-lambda-java

Amazon ECR repository: gallery.ecr.aws/lambda/java

Using a Java base image

For instructions on how to use a Java base image, choose the usage tab on Lambda base images for Java in the Amazon ECR repository.

The instructions are also available on Lambda base images for Java in the Docker Hub repository.

Java runtime interface clients

Install the runtime interface client for Java using the Apache Maven package manager. Add the following to your pom.xml file:

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-lambda-java-runtime-interface-client</artifactId>
    <version>1.0.0</version>
</dependency>

For package details, see Lambda RIC in Maven Central Repository.

You can also view the Java client source code in the AWS Lambda Java Support Libraries repository on GitHub.

After your container image resides in the Amazon ECR container registry, you can create and run the Lambda function.

Topics