Skip to content

rjozefowicz/aws-lambda-graalvm-runtime

Repository files navigation

aws-lambda-graalvm-runtime

AWS Lambda custom runtime with GraalVM native-image binary

Prerequisites

AWS Lambda custom runtime uses Amazon Linux 2 so in order to build native binary it has to be done on that OS e.g. on EC2 instance.

Set up JAVA_HOME environment variable to point GraalVM 19.3+ location e.g.

export JAVA_HOME=/home/ec2-user/graalvm-ce-java11-19.3.1

Create AWS Lambda function with custom runtime. Add IAM role with DynamoDB access and create table with primary key uuid as string type. Add AWS Lambda environment variable TABLE_NAME with table name

This example uses official AWS SDK v2 for Java to access DynamoDB table.

Custom runtime

Custom runtime is implemented according to https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html

Native-image

Most of AWS services require HTTPS communication with their endpoints. In order to make it work with native binares generated by native-image libsunec.so and cacerts are added to custom runtime archive. More details https://quarkus.io/guides/native-and-ssl#the-sunec-library-and-friends

Usage

./buildAndDeploy.sh FUNCTION_NAME