https://github.com/otbe/micronaut-aws-graal-example
https://github.com/otbe/micronaut-aws-graal-example
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/otbe/micronaut-aws-graal-example
- Owner: otbe
- Created: 2019-10-07T06:36:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-05T22:22:37.000Z (over 2 years ago)
- Last Synced: 2025-10-11T13:33:26.692Z (8 months ago)
- Language: Kotlin
- Size: 62.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Micronaut + GraalVM Native + AWS Lambda Custom Runtime
This example demonstrates how to use Micronaut AWS API Gateway Proxy support and GraalVM to construct a custom runtime that runs native images or Lambda.
The `Dockerfile` contains the build to build the native image and it can be built with:
```bash
$ docker build . -t foo
$ mkdir -p build
$ docker run --rm --entrypoint cat foo /home/application/function.zip > build/function.zip
```
Which will add the function deployment ZIP file to `build/function.zip`. You can run function locally using [SAM](https://github.com/awslabs/aws-sam-cli/)
```bash
$ docker build . -t foo
$ ./sam-local.sh
$ curl http://localhost:3000/ping
```
Or you can deploy it to AWS via the console or CLI:
```bash
aws lambda create-function --function-name foo \
--zip-file fileb://build/function.zip --handler function.handler --runtime provided \
--role ARN_OF_LAMBDA_ROLE
```
To create role for AWS Lambda, use following code:
```bash
```
The function can be invoked by sending an API Gateway Proxy request. For example:
```bash
aws lambda invoke --function-name foo --payload '{"resource": "/{proxy+}", "path": "/ping", "httpMethod": "GET"}' build/response.txt
cat build/response.txt
```
and response should be something like:
```json
{"statusCode":200,"multiValueHeaders":{},"body":"{\"pong\":true, \"graal\": true}","isBase64Encoded":false}
```
Example controller responding with /ping are included in template.
You should replace the `/ping` path entry with the URI the controller endpoint you wish to invoke.