Use Lambda Layers with Java

Introduction

I searched for the procedure for using Lambda Layers in Java, but I wrote it down because it was not easy to understand.

Preparation: Java to use

lambda layer side

Export with layer_print.jar

Print.java


package layer_print;

public class Print {
	public static void print() {
		System.out.println("print from layer!!");
	}
}
Lambda's Handler class that uses layer

Create jar without layer_print.jar → Upload to lambda function

MyLambda.java


package lambda_layer_java;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;

import layer_print.Print;

public class MyLambda implements RequestHandler<Integer, String> {
	@Override
	public String handleRequest(Integer in, Context context) {
		//lambda layer call
		Print.print();
		return "success";
	}
}

procedure

  1. Create java / lib folder locally キャプチャ1.PNG

  2. Put the jar file to be layer in lib キャプチャ2.PNG

  3. Convert java folder to zip キャプチャ3.PNG

  4. Select Layers for lambda in the AWS console. Press Create Layer キャプチャ4.PNG

  5. Enter your name and description. Select java 8 with a compatible runtime. Upload the created zip file and create a layer キャプチャ5.PNG

  6. Go to the lambda function that uses layers, select Layers and press Add Layer キャプチャ6.PNG

  7. Select layer and version to add キャプチャ7.PNG

  8. Save and complete キャプチャ8.PNG

that's all.

Recommended Posts

Use Lambda Layers with Java
How to use Java framework with AWS Lambda! ??
How to use Java API with lambda expression
Use SpatiaLite with Java / JDBC
Java lambda expressions learned with Comparator
Use java with MSYS and Cygwin
Use Microsoft Graph with standard Java
Use Azure Bing SpellCheck with Java
Use JDBC with Java and Scala.
Use Java 11 with Google Cloud Functions
Getting started with Java lambda expressions
How to use Java lambda expressions
AWS Lambda with Java starting now Part 1
[JaCoCo (Java Code Coverage)] Use with NetBeans
Hello Java Lambda
[Java] Lambda expression
[Java] Use Collectors.collectingAndThen
Working with huge JSON in Java Lambda
Java lambda expression
Interact with LINE Message API using Lambda (Java)
I want to use java8 forEach with index
Use Matplotlib from Java or Scala with Matplotlib4j
[JAVA] [Spring] [MyBatis] Use IN () with SQL Builder
Install java with Homebrew
Use ProGuard with Gradle
Change seats with java
Install Java with Ansible
java neutral lambda expression 1
Quarkus saves Java Lambda! ??
Use Puphpeteer with Docker
Comfortable download with JAVA
Understand Java 8 lambda expressions
Java lambda expression variations
Use XVim2 with Xcode 12.0.1
Use CentOS with LXD
Switch java with direnv
Use OpenCV in Java
Java 8 lambda expression Feature
java lambda expression memo
Use ngrok with Docker
Use webmock with Rspec
Download Java with Ansible
About Java lambda expressions
Java lambda expression [memo]
Explain Java 8 lambda expressions
Let's scrape with Java! !!
Studying Java 8 (lambda expression)
Use WebJars with Gradle
Review java8 ~ Lambda expression ~
Java lambda expression again
Build Java with Wercker
Use PreparedStatement in Java
Use jlink with gradle
Java Lambda Command Pattern
Endian conversion with JAVA
Use fast Mapping library MapStruct with Lombok and Java 11
How to deploy Java to AWS Lambda with Serverless Framework
Use Java lambda expressions outside of the Stream API
Use aggregate queries (Count) with Azure CosmosDB Java SDK
Play with Java function nodes that can use Java with Node-RED
Use java1.7 (zulu7) under a specific directory with jenv