Skip to content

Commit 0956f9b

Browse files
authored
Update README.md
1 parent 344b842 commit 0956f9b

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

README.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1-
# AWS Lambda Java 17 Custom Runtime (DEPRECATED)
1+
# AWS Lambda Java 21 Custom Runtime
22

3-
This project is no longer required, as [AWS Lambda now supports Java 17](https://aws.amazon.com/blogs/compute/java-17-runtime-now-available-on-aws-lambda/). I've left it here because others might find it's approach useful for other experimentation.
3+
An AWS Lambda layer to enable Java 21 support.
44

5+
## Usage
56

6-
An AWS Lambda layer to enable Java 17 support
7+
### In AWS Console
78

8-
## Usage
9+
- Download [java21layer.zip](https://github.com/aleph0io/lambda-java21-layer/releases/download/v21.0.0-alpha.0/java21layer.zip)
10+
- Upload to S3 (required to create a layer from a ZIP file greater than 50MB in size)
11+
- In Lambda console, create a layer using this ZIP file using the `x86_64` architecture and the `Custom runtime on Amazon Linux 2` runtime
12+
- In Lambda console, create a function with `Provide your own bootstrap on Amazon Linux 2` and architecture `x86_64`
13+
- In Lambda function console, add the layer you created, and upload your [Java deployment package](https://docs.aws.amazon.com/lambda/latest/dg/java-package.html)
14+
- Run
15+
- (Hopefully) celebrate! 🥳
916

1017
### with CDK
1118

12-
- Download [java17layer.zip](https://github.com/msailes/lambda-java17-layer/releases/download/v0.0.1-alpha/java17layer.zip)
13-
- Create a Lambda layer using Code.fromAsset `java17layer.zip`
19+
- Download [java21layer.zip](https://github.com/aleph0io/lambda-java21-layer/releases/download/v21.0.0-alpha.0/java21layer.zip)
20+
- Create a Lambda layer using Code.fromAsset `java21layer.zip`
1421
- Note you might need to adjust the path for your own project structure
1522

1623
```java
17-
LayerVersion java17layer = new LayerVersion(this, "Java17Layer", LayerVersionProps.builder()
18-
.layerVersionName("Java17Layer")
19-
.description("Java 17")
24+
LayerVersion java21layer = new LayerVersion(this, "Java21Layer", LayerVersionProps.builder()
25+
.layerVersionName("Java21Layer")
26+
.description("Java 21")
2027
.compatibleRuntimes(Arrays.asList(Runtime.PROVIDED_AL2))
21-
.code(Code.fromAsset("java17layer.zip"))
28+
.code(Code.fromAsset("java21layer.zip"))
2229
.build());
2330
```
2431

25-
- Create a function using the PROVIDED_AL2 runtime.
32+
- Create a function using the `PROVIDED_AL2` runtime.
2633
- Add this layer to your function.
2734

2835
```java
@@ -34,36 +41,42 @@ Function exampleWithLayer = new Function(this, "ExampleWithLayer", FunctionProps
3441
.code(Code.fromAsset("../software/ExampleFunction/target/example.jar"))
3542
.memorySize(512)
3643
.logRetention(RetentionDays.ONE_WEEK)
37-
.layers(singletonList(java17layer))
44+
.layers(singletonList(java21layer))
3845
.build());
3946
```
4047

4148
## Layer Details
4249

43-
### Java 17
50+
### Java 21
4451

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

4754
[Dockerfile](Dockerfile) describes how the JRE is built.
4855

56+
## Known Issues
57+
58+
1. The layer fails [CDS](https://docs.oracle.com/javase/8/docs/technotes/guides/vm/class-data-sharing.html) (Class Data Sharing) during initialization. This creates some log traffic, and may adversely affect performance.
59+
2. It is only (lightly) tested
60+
3. Only x86_64 is supported
61+
4962
### JVM Settings
5063

5164
The following JVM settings are added by default.
5265

5366
```
5467
--add-opens java.base/java.util=ALL-UNNAMED
5568
-XX:+TieredCompilation -XX:TieredStopAtLevel=1
56-
-Xshare:on
69+
-Xshare:auto
5770
```
5871

5972
Further suggestions welcomed
6073

6174
### Java Class Path
6275

6376
```
64-
aws-lambda-java-runtime-interface-client-1.1.0.jar
65-
aws-lambda-java-core-1.2.1.jar
66-
aws-lambda-java-serialization-1.0.0.jar
77+
aws-lambda-java-core-1.2.3.jar
78+
aws-lambda-java-serialization-1.1.2.jar
79+
aws-lambda-java-runtime-interface-client-2.4.1.jar
6780
$LAMBDA_TASK_ROOT
6881
$LAMBDA_TASK_ROOT/*
6982
$LAMBDA_TASK_ROOT/lib/*
@@ -77,6 +90,10 @@ $LAMBDA_TASK_ROOT/lib/*
7790

7891
### Steps
7992

80-
- Run `build-jre.sh` to build the minimal Java 17 runtime
93+
- Run `build-jre.sh` to build the minimal Java 21 runtime
8194
- Run `make-layer.sh` to package the runtime, dependencies and bootstrap as a zip
8295

96+
## Acknowledgements
97+
98+
Much credit to [@msailes](https://github.com/msailes), who created the original repo from which this project is forked!
99+

0 commit comments

Comments
 (0)