Skip to content

microlam-io/lambda-java17-layer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Lambda Java 17 Custom Runtime

Maven Central

Based on original work from Mark Sailes: lambda-java17-layer

With a few differences:

  • Support for Java 17 on architecture amd64 and arm64
  • Based on AWS Corretto 17 build of OpenJDK
  • The maven build create 2 artifacts for each architecture
  • The first part of the version is corresponding to the corretto version

The simplest way to bring the layer zip is to use the maven dependency plugin like this:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-dependency-plugin</artifactId>
	<version>3.2.0</version>
	<executions>
		<execution>
			<id>copy</id>
			<phase>package</phase>
			<goals>
				<goal>copy</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<artifactItems>
			<artifactItem>
				<groupId>io.microlam</groupId>
				<artifactId>lambda-java17-layer</artifactId>
				<version>17.0.2.8.1</version>
				<classifier>${java17layer.arch}</classifier>
				<type>zip</type>
			</artifactItem>
		</artifactItems>
		<outputDirectory>${project.build.directory}</outputDirectory>
		<overWriteReleases>false</overWriteReleases>
		<overWriteSnapshots>true</overWriteSnapshots>
	</configuration>
</plugin>

Where property java17layer.arch may be amd64 or arm64.

Then the simplest way to deploy it to AWS is to use the CDK:

//Choose your architecture
Architecture architecture = Architecture.X86_64; // Architecture.ARM_64 or Architecture.X86_64

//Do not modify this
String arch = (architecture == Architecture.ARM_64)?"arm64":"amd64";
        
LayerVersion java17layer = new LayerVersion(this, "Java17Layer-"+ arch, LayerVersionProps.builder()
				        .layerVersionName("Java17Layer-" + arch)
				        .description("Java 17 " + arch)
				        .compatibleRuntimes(Arrays.asList(software.amazon.awscdk.services.lambda.Runtime.PROVIDED_AL2))
				        .code(Code.fromAsset("target/lambda-java17-layer-17.0.2.8.1-"+ arch + ".zip"))
				        .build());

Function handlerBuilder = Function.Builder.create(this, "SimpleLambda")			    		  
           .functionName("SimpleLambda")
           .architecture(architecture)
           .runtime(software.amazon.awscdk.services.lambda.Runtime.PROVIDED_AL2)
           .layers(Collections.singletonList(java17layer))
           .handler("example.lambda.SimpleLambda")
           .memorySize(512)
           .timeout(Duration.seconds(20))
           .code(Code.fromAsset("target/simple-lambda-1.0-SNAPSHOT-aws-lambda.zip")).build();

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages