Skip to content
John Fereira edited this page Apr 5, 2022 · 1 revision

LambdaWebapp

Contents

The project source includes function code and supporting resources:

  • src/main - A Java function.
  • sam.yml - An AWS CloudFormation template that creates an application.
  • Dockerfile - A Docker 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.

Requirements

Setup

Download or clone this repository.

$ git clone https://github.com/fereira/javadev    
$ cd javadev/LambdaWebApp

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: lambda-webapp-demo-a5e491dbb5b22e0d

Deploy

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.

Invoke

To invoke the function, run 3-invoke.sh. This will test the function three times

 $ ./3-invoke.sh
 {
    "StatusCode": 200,
    "ExecutedVersion": "$LATEST"
} 

Cleanup

To delete the application, run 6-cleanup.sh.

$ ./4-cleanup.sh
Clone this wiki locally