This project creates a function and supporting resources:
- src - A Java function.
- template.yml - An AWS CloudFormation template that creates an application.
- build.gradle - A Gradle 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 8 runtime environment (SE JRE)
- Gradle 5
- 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.
Download or clone this repository.
$ git clone git@github.com:awsdocs/aws-lambda-developer-guide.git
$ cd aws-lambda-developer-guide/sample-apps/java-s3
Run 1-create-bucket.sh to create a new bucket for deployment artifacts. Or, if you already have a bucket, rename 2-deploy.sh.template to 2-deploy.sh and replace MY_BUCKET in it with the name of an existing bucket.
java-s3$ ./1-create-bucket.sh
make_bucket: lambda-artifacts-a5e491dbb5b22e0d
Run 2-deploy.sh to deploy the application.
java-s3$ ./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 - java-s3
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.
Run 3-invoke.sh to invoke the function.
java-s3$ ./3-invoke.sh
{
"StatusCode": 200,
"ExecutedVersion": "$LATEST"
}
The functions in this application are instrumented with AWS X-Ray. Open the X-Ray console to view the service map.
Choose a node in the main function graph. Then choose View traces to see a list of traces. Choose any trace to view a timeline that breaks down the work done by the function.
Finally, view the application in the Lambda console.
To view the output
- Open the applications page in the Lambda console.
- Choose java-s3.
To delete the application, run 4-cleanup.sh.
blank$ ./4-cleanup.sh



