Skip to content

anmol95/orderprocessingsystem

Repository files navigation

Order Processing System

This sample application hosts the complete order processing system.

The project 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-build-layer.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

If you use the AWS CLI v2, add the following to your configuration file (~/.aws/config):

cli_binary_format=raw-in-base64-out

This setting enables the AWS CLI v2 to load JSON events from a file, matching the v1 behavior.

Setup

Download or clone this repository.

$ git clone https://github.com/anmol95/orderprocessingsystem
$ cd orderprocessingsystem

Run 1-create-bucket.sh to create a new bucket for deployment artifacts.

orderprocessingsystem$ ./1-create-bucket.sh
make_bucket: lambda-artifacts-a5e4xmplb5b22e0d

To build a Lambda layer that contains the function's runtime dependencies, run 2-build-layer.sh. Packaging dependencies in a layer reduces the size of the deployment package that you upload when you modify your code.

orderprocessingsystem$ ./2-build-layer.sh

Deploy

Run 3-deploy.sh to build the application with Gradle and deploy it.

orderprocessingsystem$ ./3-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 - orderprocessingsystem

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.

orderprocessingsystem$ ./3-deploy.sh mvn
[INFO] Scanning for projects...
[INFO] -----------------------< com.orderprocessingsystem:orderprocessingsystem >-----------------------
[INFO] Building orderprocessingsystem-function 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
...

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.

Configure Handler Class

To use a different handler, change the value of the Handler setting in the application template (template.yml or template-mvn.yaml). For example, to use the Kinesis handler:

Properties:
  CodeUri: build/distributions/orderprocessingsystem.zip
  Handler: orderprocessingsystem.Handler

Deploy the change, and then use the invoke script to test the new configuration. Pass the handler type key as an argument to the invoke script.

./4-invoke.sh kin
{
    "StatusCode": 200,
    "ExecutedVersion": "$LATEST"
}
"200 OK"

Cleanup

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

orderprocessingsystem$ ./5-cleanup.sh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors