You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As above, commands can be stacked. The only requirement is that `native` be the first parameter should you wish
211
+
to work with native image builds. The script will take care of the rest of the details necessary to manage your native
212
+
image function deployments.
213
+
247
214
== Examine the POM
248
215
249
-
If you want to adapt an existing project to use Quarkus's Amazon Lambda extension, there's a couple
216
+
If you want to adapt an existing project to use Quarkus's Amazon Lambda extension, there are a couple
250
217
of things you need to do. Take a look at the generated example project to get an example of what you need to adapt.
251
218
252
219
1. Include the `quarkus-amazon-lambda` extension as a pom dependency
253
220
2. Configure Quarkus to build an `uber-jar` (via quarkus.package.uber-jar=true in the application.properties)
254
-
3. If you are doing a native image build, Amazon requires you to rename your executable to `bootstrap` and zip it up. Notice that the `pom.xml` uses the `maven-assembly-plugin` to perform this requirement.
221
+
3. If you are doing a native image build, Amazon requires you to rename your executable to `bootstrap` and zip it up.
222
+
Notice that the `pom.xml` uses the `maven-assembly-plugin` to perform this requirement.
255
223
256
224
NB: With gradle, to build the uber-jar execute: ./gradlew quarkusBuild --uber-jar
257
225
258
226
== Testing with the SAM CLI
259
227
260
-
The https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html[AWS SAM CLI] allows you to run your lambdas locally on your laptop in a simulated Lambda environment. This requires https://www.docker.com/products/docker-desktop[docker] to be installed.
228
+
The https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html[AWS SAM CLI]
229
+
allows you to run your lambdas locally on your laptop in a simulated Lambda environment. This requires
230
+
https://www.docker.com/products/docker-desktop[docker] to be installed. This is an optional approach should you choose
231
+
to take advantage of it. Otherwise, dev mode should be sufficient for most of your needs.
261
232
262
-
To execute your lambda function with the
263
-
`java8` runtime, create a `sam.jvm.yaml` template as below:
Run the following SAM CLI command to test your lambda function with the `Java8` runtime and `sam.jvm.yaml` template:
283
-
----
284
-
sam local invoke --template sam.jvm.yaml --event {json test file}
285
-
----
286
-
287
-
The native executable can be tested via the `provided` runtime defined in a `sam.native.yaml` template:
288
-
----
289
-
AWSTemplateFormatVersion: '2010-09-09'
290
-
Transform: AWS::Serverless-2016-10-31
291
-
292
-
Globals:
293
-
Function:
294
-
Timeout: 5
295
-
Resources:
296
-
QuarkusSam:
297
-
Type: AWS::Serverless::Function
298
-
Properties:
299
-
Handler: not.used.in.provided.runtimei
300
-
Runtime: provided
301
-
CodeUri: {path to function.zip}
302
-
MemorySize: 128
303
-
Policies: AWSLambdaBasicExecutionRole
304
-
Timeout: 15
305
-
Environment:
306
-
Variables:
307
-
DISABLE_SIGNAL_HANDLERS: true
308
-
----
309
-
310
-
311
-
When using the `provided` runtime, AWS requires a bootstrap script to trigger the native executable. Bundle the `bootstrap` script along with the *-runner executable.
233
+
A starter template has been generated for both JVM and native execution modes.
312
234
313
-
i.e., create a zip file called `function.zip` with:
235
+
Run the following SAM CLI command to locally test your lambda function:
314
236
315
-
* bootstrap
316
-
* {projectname-version}-runner
317
-
318
-
Example `bootstrap` script to load the native executable:
237
+
[source]
319
238
----
320
-
#!/usr/bin/env bash
321
-
322
-
RUNNER=$( find . -maxdepth 1 -name '*-runner' )
323
-
if [[ ! -z "$RUNNER" ]]
324
-
then
325
-
$RUNNER
326
-
fi
239
+
sam local invoke --template sam.jvm.yaml --event {json test file}
327
240
----
328
241
329
-
To invoke the native `provided` runtime with the `sam.native.yaml` template, use the following command:
242
+
The native image can also be locally tested using the `sam.native.yaml` template:
330
243
244
+
[source]
331
245
----
332
246
sam local invoke --template sam.native.yaml --event {json test file}
0 commit comments