Skip to content

Commit f5d770e

Browse files
committed
added CDK instructions
1 parent 8998def commit f5d770e

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,42 @@ AWS Lambda layer to enable Java 17 support
33

44
## Usage
55

6+
### with CDK
7+
8+
- Download [java17layer.zip](https://github.com/msailes/lambda-java17-layer/releases/download/v0.0.1-alpha/java17layer.zip)
9+
- Create a Lambda layer using Code.fromAsset `java17layer.zip`
10+
- Note you might need to adjust the path for your own project structure
11+
12+
```java
13+
LayerVersion java17layer = new LayerVersion(this, "Java17Layer", LayerVersionProps.builder()
14+
.layerVersionName("Java17Layer")
15+
.description("Java 17")
16+
.compatibleRuntimes(Arrays.asList(Runtime.PROVIDED_AL2))
17+
.code(Code.fromAsset("java17layer.zip"))
18+
.build());
19+
```
20+
621
- Create a function using the PROVIDED_AL2 runtime.
722
- Add this layer to your function.
823

24+
```java
25+
Function exampleWithLayer = new Function(this, "ExampleWithLayer", FunctionProps.builder()
26+
.functionName("example-with-layer")
27+
.description("example-with-layer")
28+
.handler("example.HelloWorld::handleRequest")
29+
.runtime(Runtime.PROVIDED_AL2)
30+
.code(Code.fromAsset("../software/ExampleFunction/target/example.jar"))
31+
.memorySize(512)
32+
.logRetention(RetentionDays.ONE_WEEK)
33+
.layers(singletonList(java17layer))
34+
.build());
35+
```
36+
937
## Java 17
1038

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

13-
[Dockerfile](Dockerfile) describes how the JRE is built
41+
[Dockerfile](Dockerfile) describes how the JRE is built.
1442

1543
## JVM Settings
1644

0 commit comments

Comments
 (0)