This project demonstrates the Lambda for Powertools Java module deployed using Serverless Application Model running as a GraalVM native image.
For general information on the deployed example itself, you can refer to the parent README
-
SAM uses template.yaml to define the application's AWS resources. This file defines the Lambda function to be deployed as well as API Gateway for it.
-
Set the environment to use GraalVM
export JAVA_HOME=<path to GraalVM>
- Build the Docker image that will be used as the environment for SAM build:
docker build --platform linux/amd64 . -t powertools-examples-core-sam-graalvm
- Build the SAM project using the docker image
sam build --use-container --build-image powertools-examples-core-sam-graalvm
- If you are testing the example with a -SNAPSHOT version of PowerTools, the maven build inside the docker image will fail. This is because the -SNAPSHOT version of the PowerTools library that you are working on is still not available in maven central/snapshot repository.
To get around this, follow these steps:
- Create the native image using the
docker
command below on your development machine. The native image is created in thetarget
directory.docker run --platform linux/amd64 -it -v `pwd`:`pwd` -w `pwd` -v ~/.m2:/root/.m2 powertools-examples-core-sam-graalvm mvn clean -Pnative-image package -DskipTests
- Edit the
Makefile
remove this linemvn clean package -P native-image
- Build the SAM project using the docker image
sam build --use-container --build-image powertools-examples-core-sam-graalvm
- Create the native image using the
-
SAM deploy
sam deploy
To deploy the example, check out the instructions for getting started with SAM in the examples directory
You can watch the trace information or log information using the SAM CLI:
# Tail the logs
sam logs --tail $MY_STACK
# Tail the traces
sam traces --tail