Skip to content

Latest commit

 

History

History

Blank function (Go)

Architecture

The project source includes function code and supporting resources:

  • function - A Golang 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.

Requirements

Setup

Download or clone this repository.

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

To create a new bucket for deployment artifacts, run 1-create-bucket.sh.

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

Deploy

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

blank-go$ ./2-deploy.sh
Successfully packaged artifacts and wrote output template to file out.yml.
Waiting for changeset to be created..
Successfully created/updated stack - blank-go

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-go$ ./3-invoke.sh
{
    "StatusCode": 200,
    "ExecutedVersion": "$LATEST"
}
"{\"FunctionCount\":42,\"TotalCodeSize\":361861771}"

Let the script invoke the function a few times and then press CRTL+C to exit.

The application uses AWS X-Ray to trace requests. Open the X-Ray console to view the service map.

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

Cleanup

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

blank$ ./4-cleanup.sh