Skip to content

Latest commit

 

History

History
 
 

README.md

Blank function

Architecture

This project creates a function and supporting resources:

  • function - A Node.js function.
  • template.yml - An AWS CloudFormation template that creates an application.
  • 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.

TODO

When you adapt this project for your own application, complete the following tasks.

  • Change stack name in 2-deploy.sh, 3-invoke.sh, 4-cleanup.sh
  • (optional) Change function name in template.yml, 3-invoke.sh
  • (optional) Change function folder name in template.yml, 2-deploy.sh.template

Requirements

Setup

Download or clone this repository.

$ git clone git@github.com:awsdocs/aws-lambda-developer-guide.git
$ cd aws-lambda-developer-guide/sample-apps/blank

To create a new bucket for deployment artifacts, run 1-create-bucket.sh. Or, if you already have a bucket, create a file named bucket-name.txt that contains the name of your bucket.

blank$ ./1-create-bucket.sh
make_bucket: lambda-artifacts-a5e491dbb5b22e0d

Deploy

To deploy the application, run 2-deploy.sh.

blank$ ./2-deploy.sh
added 16 packages from 18 contributors and audited 18 packages in 0.926s
added 17 packages from 19 contributors and audited 19 packages in 0.916s
Uploading to e678bc216e6a0d510d661ca9ae2fd941  2737254 / 2737254.0  (100.00%)
Successfully packaged artifacts and wrote output template to file out.yml.
Waiting for changeset to be created..
Waiting for stack create/update to complete
Successfully created/updated stack - blank

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.

Test

To invoke the function, run 3-invoke.sh.

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

The application uses AWS X-Ray to trace requests. Open the X-Ray console to view the service map. The following service map shows the function calling Amazon S3.

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.

Trace

Finally, view the application in the Lambda console.

To view the output

  1. Open the applications page in the Lambda console.
  2. Choose blank.

Application

Cleanup

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

blank$ ./4-cleanup.sh