Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM oracle/graalvm-ce:19.0.2
RUN gu install native-image
WORKDIR /app
36 changes: 5 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,10 @@ Make sure you have the following installed on your build machine before getting
$ ./mvnw package
```

#### Create the Lambda Custom Runtime Entry Point

AWS Lambda Custom Runtimes require an executable file in the root directory named simply ```bootstrap```. This can be any executable file, for our case we're going to just use
a shell script to call our launcher that we created in the step above. This script will do nothing more than invoke our Java Runtime from the dist folder.

##### Create the bootstrap script
```
$ touch boostrap
```
##### Call our Java Runtime from Bash

Add the following commands to the ```bootstrap```
```$bash
#!/bin/sh
/opt/target/lambda
```

Note that the path we're using in our shell script is ```/opt```. When you create a Lambda Layer, as we'll do shortly, AWS Lambda copies all the runtime files to the ```/opt``` directory. This directory is effectively the home directory for our custom runtime.

##### Make bootstrap executable
```
$ chmod +x bootstrap
```

##### Create a deployment package

In the root of the folder containing our ```bootstrap``` and ```target/lambda``` files, create a zip archive containing the artifacts.
If your system cannot build working images (say to mismatch of library versions), you can build under docker:

```
$ zip -r function.zip bootstrap target/lambda
docker run --rm -it -v ${PWD}:/app:z builder /bin/bash
```

### Deploying to AWS Lambda
Expand Down Expand Up @@ -86,7 +60,7 @@ Where the file `/tmp/trust-policy.json` contains:
```
aws lambda publish-layer-version \
--layer-name vertx-native-example \
--zip-file fileb://function.zip
--zip-file fileb://target/lambda-0.0.1-SNAPSHOT-function.zip
```

#### Create a function
Expand All @@ -95,14 +69,14 @@ aws lambda publish-layer-version \
aws lambda delete-function --function-name vertxNativeTester

aws lambda create-function --function-name vertxNativeTester \
--zip-file fileb://function.zip --handler lambda.EchoLambda --runtime provided \
--zip-file fileb://target/lambda-0.0.1-SNAPSHOT-function.zip --handler lambda.ApplicationLoadBalancerLambda --runtime provided \
--role arn:aws:iam::985727241951:role/service-role/lambda-role
```

#### Link the layer to the function

```
aws lambda update-function-configuration --function-name vertxNativeTester --layers arn:aws:lambda:eu-central-1:985727241951:layer:vertx-native-example:8
aws lambda update-function-configuration --function-name vertxNativeTester --layers arn:aws:lambda:eu-central-1:985727241951:layer:vertx-native-example:1
```

#### Test it
Expand Down
146 changes: 146 additions & 0 deletions boilerplate/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
</parent>

<groupId>xyz.jetdrone</groupId>
<artifactId>vertx.lambda.aws</artifactId>
<version>0.0.2</version>

<name>vertx-lambda-aws</name>
<description>Boilerplate for a native vert.x AWS lambda</description>
<url>https://github.com/pmlopes/aws-lambda-native-vertx</url>


<licenses>
<license>
<name>Apache License, Version 2.0</name>
<distribution>repo</distribution>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
</license>
</licenses>


<issueManagement>
<url>https://github.com/pmlopes/aws-lambda-native-vertx/issues</url>
<system>GitHub Issues</system>
</issueManagement>

<scm>
<url>https://github.com/pmlopes/aws-lambda-native-vertx</url>
<connection>scm:git:git://github.com/pmlopes/aws-lambda-native-vertx.git</connection>
<developerConnection>scm:git:[email protected]:pmlopes/aws-lambda-native-vertx.git</developerConnection>
</scm>

<developers>
<developer>
<id>pmlopes</id>
<name>Paulo Lopes</name>
<email>[email protected]</email>
</developer>
</developers>

<ciManagement>
<url>https://travis-ci.org/pmlopes/aws-lambda-native-vertx</url>
<system>Travis CI</system>
</ciManagement>


<distributionManagement>
<site>
<id>website</id>
<url>https://github.com/pmlopes/aws-lambda-native-vertx</url>
</site>
</distributionManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<graal.version>19.0.0</graal.version>
<vertx.version>3.7.1</vertx.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
<version>${vertx.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm-driver</artifactId>
<version>${graal.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-codegen</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-client</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-unit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<!-- Configure the execution of the compiler to execute the codegen processor -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<testSource>1.8</testSource>
<testTarget>1.8</testTarget>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<annotationProcessors>
<annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
</annotationProcessors>
<compilerArgs>
<arg>-Acodegen.output=${project.basedir}/src/main</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Loading