-
Notifications
You must be signed in to change notification settings - Fork 0
LambdaDemo
The project source includes function code and supporting resources:
-
src/main
- A Java function. -
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 11 runtime
- Maven 3
- The Bash shell.
- The AWS CLI v2 or newer.
Download or clone this repository.
$ git clone https://github.com/fereira/javadev
$ cd javadev/LambdaDemo
Copy the awsenv-example.sh
script to awsenv.sh
to set variables for the AWS_ACCESS_KEY
and AWS_SECRET_ACCESS_KEY
To create a new bucket for deployment artifacts, run 1-create-bucket.sh
.
$ ./1-create-bucket.sh
make_bucket: aws-lambda-demo-app-a5e491dbb5b22e0d
To build and deploy, run the 2-deploy.sh script. This will run maven to compile the code, then will use aws cloudformation and the template.yml
file to copy the resources to a stack.
To deploy the application, run 2-deploy.sh
.
$ ./2-deploy.sh
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.
To test, execute the s3-invoke.sh
script
s3-java$ ./3-invoke.sh
{
"StatusCode": 200,
"ExecutedVersion": "$LATEST"
}
The function will execute 3 times
To delete the application, run 6-cleanup.sh
.
$ ./4-cleanup.sh