A Giter8 template for creating simple scala lambda project using scala-aws-lambda-runtime
-
Go to directory where you want to create the template
-
Decide your project name (the hardest part :))
-
Run the command like
sbt new encalmo/scala-aws-lambda-seed.g8 --branch main --lambdaName="ExampleLambda" --awsAccountId="047719648492" --awsRegion="eu-central-1" --package="org.encalmo.lambda.example" -o scala-aws-lambda-seed
or
-
Install g8 commandline tool (http://www.foundweekends.org/giter8/setup.html)
-
Run the command like
g8 encalmo/scala-aws-lambda-seed.g8 --branch main --lambdaName="ExampleLambda" --awsAccountId="047719648492" --awsRegion="eu-central-1" --package="org.encalmo.lambda.example" -o scala-aws-lambda-seed
and then
cd scala-aws-lambda-seed
git init
git add .
git commit -m start
-
Test generated project using command
./test.sh
- Run
./test.sh
An example project will be then created and tested in target/sandbox/scala-aws-lambda-seed
- review template sources in
/src/main/g8
- modify files as you need, but be careful about placeholders, paths and so on
- run
./test.sh
in template root to validate your changes
or (safer) ...
- run
./test.sh
first - open
target/sandbox/scala-aws-lambda-seed
in your preferred IDE, - modify the generated example project as you wish,
- build and test it as usual, you can run
./test.sh
, - when you are done switch back to the template root
- run
./update-g8.sh
in order to port your changes back to the template. - run
./test.sh
again to validate your changes
Assuming the command above the template will supply the following values for the placeholders:
$packaged$ -> org/encalmo/lambda/example
$package$ -> org.encalmo.lambda.example
$lambdaName$ -> ExampleLambda
$awsAccountId$ -> 047719648492
$awsRegion$ -> eu-central-1
and produce the folders and files as shown below:
├── .github
│ └── workflows
│ └── buildAndDeployLambda.yaml
│
├── .gitignore
├── .scalafmt.conf
├── build.sh
├── ExampleLambda.scala
├── ExampleLambda.test.scala
├── lambda-deployment-config.json
├── LICENSE
├── project.scala
├── README.md
├── reflect.json
├── run.sh
├── scripts
│ ├── buildAndDeployLambdaAssembly.sh
│ ├── buildAndDeployLambdaNativePackage.sh
│ ├── buildAndRunLambdaAssembly.sh
│ ├── buildAndRunLambdaNativePackage.sh
│ ├── buildLambdaAssembly.sh
│ ├── buildLambdaNativePackage.sh
│ ├── deployLambda.sc
│ ├── runLambdaAssembly.sh
│ ├── runLambdaLocallyUsingCommandLine.sh
│ ├── runLambdaLocallyUsingWebBrowser.sh
│ └── runLambdaNativePackage.sh
│
├── test.sh
└── TestSuite.test.scala