awslabs/aws-lambda-deploy

Name: aws-lambda-deploy

Owner: Amazon Web Services - Labs

Owner: AWS Samples

Description: A collection of tools to enable canary deployments of AWS Lambda functions.

Created: 2017-10-05 19:02:39.0

Updated: 2018-01-13 18:33:14.0

Pushed: 2017-11-30 19:27:11.0

Homepage:

Size: 14

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

aws-lambda-deploy

A collection of tools to enable canary deployments of AWS Lambda functions.

Full background and examples can be found in Implementing Canary Deployments of AWS Lambda Functions with Alias Traffic Shifting on the AWS Compute Blog.

Installation

Please ensure you have the AWS CLI installed and configured with credentials.

The install script uses SAM to deploy relevant resources to your AWS account:

t clone https://github.com/awslabs/aws-lambda-deploy
 aws-lambda-deploy
port BUCKET_NAME=[S3_BUCKET_NAME_FOR_BUILD_ARTIFACTS]
install.sh
Simple deployment function

This simple Python script runs as a Lambda function and deploys another function by incrementally increasing the weight of the new function version over a prescribed number of steps, while checking the health of the new version.

If the health check fails, the alias is rolled back to its initial version. The health check is implemented as a simple check against the existence of Errors metrics in CloudWatch for the alias and new version.

llout version 2 incrementally over 10 steps, with 120s between each step
s lambda invoke --function-name SimpleDeployFunction --log-type Tail --payload \
{"function-name": "MyFunction",
alias-name": "MyAlias",
new-version": "2",
steps": 10,
interval" : 120,
type": "linear"
' output
Deployment workflow

This state machine performs essentially the same task as the simple deployment function, but it runs as an asynchronous workflow in AWS Step Functions, with a maximum timeout of 1 year.

The step function will incrementally update the new version weight based on the “steps” parameter, waiting for some time based on the “interval” parameter, and performing health checks between updates. If the health check fails, the alias will be rolled back to the original version and the workflow will fail.

port STATE_MACHINE_ARN=`aws cloudformation describe-stack-resources --stack-name aws-lambda-deploy-stack --logical-resource-id DeployStateMachine --output text | cut  -d$'\t' -f3`
s stepfunctions start-execution --state-machine-arn $STATE_MACHINE_ARN --input '{
ction-name": "MyFunction",
as-name": "MyAlias",
-version": "2",
ps": 10,
erval": 120,
e": "linear"}'

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.