8000 GitHub - msailes/lambda-java17-layer at f5d770e74a3ba3bdaadf0b94068febcee451d3e5
[go: up one dir, main page]

Skip to content

msailes/lambda-java17-layer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lambda-java17-layer

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());

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/*

About

AWS Lambda layer to enable Java 17 support

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  
0