Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

msailes/lambda-java17-layer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Lambda Java 17 Custom Runtime

An AWS Lambda layer to enable Java 17 support

Usage

with CDK

  • Download java17layer.zip
  • Create a Lambda layer using Code.fromAsset java17layer.zip
  • Note you might need to adjust the path for your own project structure
LayerVersion java17layer = new LayerVersion(this, "Java17Layer", LayerVersionProps.builder()
        .layerVersionName("Java17Layer")
        .description("Java 17")
        .compatibleRuntimes(Arrays.asList(Runtime.PROVIDED_AL2))
        .code(Code.fromAsset("java17layer.zip"))
        .build());
  • Create a function using the PROVIDED_AL2 runtime.
  • Add this layer to your function.
Function exampleWithLayer = new Function(this, "ExampleWithLayer", FunctionProps.builder()
        .functionName("example-with-layer")
        .description("example-with-layer")
        .handler("example.HelloWorld::handleRequest")
        .runtime(Runtime.PROVIDED_AL2)
        .code(Code.fromAsset("../software/ExampleFunction/target/example.jar"))
        .memorySize(512)
        .logRetention(RetentionDays.ONE_WEEK)
        .layers(singletonList(java17layer))
        .build());

Layer Details

Java 17

A custom JRE is created to reduce final file size. Lambda has a 250MB unzipped file size limit.

Dockerfile describes how the JRE is built.

JVM Settings

The following JVM settings are added by default.

--add-opens java.base/java.util=ALL-UNNAMED 
-XX:+TieredCompilation -XX:TieredStopAtLevel=1 
-Xshare:on

Further suggestions welcomed

Java Class Path

aws-lambda-java-runtime-interface-client-1.1.0.jar
aws-lambda-java-core-1.2.1.jar
aws-lambda-java-serialization-1.0.0.jar
$LAMBDA_TASK_ROOT
$LAMBDA_TASK_ROOT/*
$LAMBDA_TASK_ROOT/lib/*

Build the layer zip yourself

Requirements

  • Docker

Steps

  • Run build-jre.sh to build the minimal Java 17 runtime
  • Run make-layer.sh to package the runtime, dependencies and bootstrap as a zip

About

AWS Lambda layer to enable Java 17 support

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.