The project source includes function code and supporting resources:
src/main
- A Java function.src/test
- A unit test and helper classes.template.yml
- An AWS CloudFormation template that creates an application.build.gradle
- A Gradle build file.pom.xml
- A Maven build file.1-create-bucket.sh
,2-deploy.sh
, etc. - Shell scripts that use the AWS CLI to deploy and manage the application.
Use the following instructions to deploy the sample application.
- Java 17 runtime environment (SE JRE)
- Gradle 5 or Maven 3
- The Bash shell. For Linux and macOS, this is included by default. In Windows 10, you can install the Windows Subsystem for Linux to get a Windows-integrated version of Ubuntu and Bash.
- The AWS CLI v1.17 or newer.
Download or clone this repository.
$ git clone https://github.com/benveniste/blockchainLambda
$ cd blockchainLambda
To create a new bucket for deployment artifacts, run 1-create-bucket.sh
.
blockchainLambda$ ./1-create-bucket.sh
make_bucket: lambda-artifacts-a5e4xmplb5b22e0d
To deploy the application, run 2-deploy.sh
.
blockchainLambda$ ./2-deploy.sh
BUILD SUCCESSFUL in 1s
Successfully packaged artifacts and wrote output template to file out.yml.
Waiting for changeset to be created..
Successfully created/updated stack - blockchainLambda
This script uses AWS CloudFormation to deploy the Lambda functions and an IAM role. If the AWS CloudFormation stack that contains the resources already exists, the script updates it with any changes to the template or function code.
You can also build the application with Maven. To use maven, add mvn
to the command.
blockchainLambda$ ./2-deploy.sh mvn
[INFO] Scanning for projects...
[INFO] -----------------------< com.example:blockchainLambda >-----------------------
[INFO] Building blockchainLambda-function 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
...
To invoke the function, run 3-invoke.sh
.
blockchainLambda$ ./3-invoke.sh
{
"StatusCode": 200,
"ExecutedVersion": "$LATEST"
}
21
Let the script invoke the function a few times and then press CRTL+C
to exit.
To delete the application, run 4-cleanup.sh
.
blockchainLambda$ ./4-cleanup.sh