|
1 | 1 | # graalvm-scala-lambda
|
2 | 2 |
|
| 3 | + |
3 | 4 | A Hello, World app for AWS Lambda. Written in Scala, compiled with the GraalVM and executed with the AWS Lambda Custom Runtime.
|
4 | 5 |
|
| 6 | + |
| 7 | +This is the example project for my [AWS Lambda, Scala, and GraalVM](https://www.bks2.com/2019/05/17/scala-lambda-functions-with-graalvm/) |
| 8 | +blog post. |
| 9 | + |
| 10 | + |
| 11 | +## Requirements |
| 12 | + |
| 13 | +This project uses SBT for building Scala projects, Docker for further compiling the Scala code to a linux executable, |
| 14 | +and Amazon's SAM CLI app for testing/packaging/deploying AWS Lambda functions. You'll need all of the following to run the project: |
| 15 | + |
| 16 | +1. [SBT](https://www.scala-sbt.org/) |
| 17 | + * The Scala Build Tool |
| 18 | +1. [SAM CLI](https://aws.amazon.com/serverless/sam/) |
| 19 | + * The AWS Serverless Application Model app (a wrapper around AWS CloudFormation and the CLI) |
| 20 | +1. [AWS CLI](https://aws.amazon.com/cli/) |
| 21 | + * The popular CLI for accessing the AWS API |
| 22 | +1. [Docker](https://www.docker.com/) |
| 23 | + * Required by SAM for local testing of Lambda functions |
| 24 | +1. curl |
| 25 | + * The performant web client used to test the running Lambda functions |
| 26 | +1. An AWS account and valid credentials |
| 27 | + * Allows the SAM tool to deploy your function to API Gateway / AWS Lambda |
| 28 | + |
| 29 | +## Building and Running The Function Locally |
| 30 | + |
| 31 | +Open your terminal to the project directory and run the following to build and run the function locally: |
| 32 | + |
| 33 | + $ ./build.sh && sam local start-api |
| 34 | + |
| 35 | +Open a separate terminal in the same directory and test out the function with `curl`: |
| 36 | + |
| 37 | + $ curl http://127.0.0.1:3000/hello/developer |
| 38 | + Hello, developer |
| 39 | + |
| 40 | +The `Hello, $name` response from the function appears, with the name taken from the path parameter following the `hello/` segment. |
| 41 | + |
| 42 | +See the [post](https://www.bks2.com/2019/05/17/scala-lambda-functions-with-graalvm/) for the remaining instructions on uploading and deploying your function |
| 43 | +to AWS Lambda. |
| 44 | + |
0 commit comments