From 3a97b5b8e4c4d8654f123f3ff846d3947bbecd84 Mon Sep 17 00:00:00 2001 From: EzxD Date: Tue, 1 Dec 2020 15:29:55 +0100 Subject: [PATCH] Add AWS funqy support --- README.md | 24 +++++++++++++++++++ payload.json | 4 ++++ pom.xml | 4 ++++ .../serverless/function/UserFunction.java | 2 +- .../serverless/service/UserService.java | 2 +- src/main/resources/application.properties | 1 + .../test/unit/repository/RepositoryTest.java | 2 +- src/test/resources/application.properties | 1 + 8 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 payload.json diff --git a/README.md b/README.md index 4cddb5a..32a142f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,30 @@ Our goal was to have functions with a low memory footprint and extremely fast co > mvn package -Pnative -Dquarkus.native.container-build=true +## AWS +Specify your function in the ``application.properties`` with ``quarkus.funqy.export=helloWorld``. + +The function name is based on the function in the ``HelloWorldFunction.class`` in the case it`s ``helloWorld``. + +You need to add ``LAMBDA_ROLE_ARN`` with your role to your enviroment variables or add it to the ``manage.sh`` file. + +### Native deployment + +> mvn package -Pnative -Dquarkus.native.container-build=true + +> sh target/manage.sh native create + +## Testing +You can use the SAM CLI to test your aws lamda locally. + +### JVM +> sam local invoke --template target/sam.jvm.yaml --event payload.json + +### Native +> sam local invoke --template target/sam.native.yaml --event payload.json + ## Sources [Quarkus - Building native image](https://quarkus.io/guides/building-native-image) + +[Quarkus - Funqy Amazon Lamda](https://quarkus.io/guides/funqy-amazon-lambda) diff --git a/payload.json b/payload.json new file mode 100644 index 0000000..bd1db97 --- /dev/null +++ b/payload.json @@ -0,0 +1,4 @@ +{ + "username": "testUser" + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8dd5ee2..36fe475 100644 --- a/pom.xml +++ b/pom.xml @@ -42,6 +42,10 @@ quarkus-funqy-http compile + + io.quarkus + quarkus-funqy-amazon-lambda + io.quarkus quarkus-resteasy diff --git a/src/main/java/de/stvehb/example/serverless/function/UserFunction.java b/src/main/java/de/stvehb/example/serverless/function/UserFunction.java index ad01ee9..6e94153 100644 --- a/src/main/java/de/stvehb/example/serverless/function/UserFunction.java +++ b/src/main/java/de/stvehb/example/serverless/function/UserFunction.java @@ -10,7 +10,7 @@ public class UserFunction { @Inject - private UserService userSer; + UserService userSer; @Funq public void createUser(@Valid UserDTO userDTO) { diff --git a/src/main/java/de/stvehb/example/serverless/service/UserService.java b/src/main/java/de/stvehb/example/serverless/service/UserService.java index db333e8..b2e9030 100644 --- a/src/main/java/de/stvehb/example/serverless/service/UserService.java +++ b/src/main/java/de/stvehb/example/serverless/service/UserService.java @@ -11,7 +11,7 @@ public class UserService { @Inject - private UserRepository userRepository; + UserRepository userRepository; @Transactional public void createUser(String username) { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 9021322..e687838 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,3 +4,4 @@ #quarkus.datasource.jdbc.url = jdbc:postgresql://localhost:5432/mydatabase #quarkus.datasource.driver=org.postgresql.Driver quarkus.hibernate-orm.database.generation=drop-and-create +quarkus.funqy.export=helloWorld diff --git a/src/test/java/de/stvehb/example/serverless/test/unit/repository/RepositoryTest.java b/src/test/java/de/stvehb/example/serverless/test/unit/repository/RepositoryTest.java index 48422e7..ee8c148 100644 --- a/src/test/java/de/stvehb/example/serverless/test/unit/repository/RepositoryTest.java +++ b/src/test/java/de/stvehb/example/serverless/test/unit/repository/RepositoryTest.java @@ -22,7 +22,7 @@ public class RepositoryTest { @Inject - private UserRepository userRepository; + UserRepository userRepository; @Test @Transactional diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 57588f2..2d4e5ed 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -2,3 +2,4 @@ quarkus.datasource.db-kind=h2 quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test quarkus.hibernate-orm.database.generation=drop-and-create quarkus.hibernate-orm.log.sql=true +quarkus.funqy.export=helloWorld