Coder Social home page Coder Social logo

kmridha92 / aws-lambda-deploy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws-samples/aws-lambda-deploy

0.0 1.0 0.0 14 KB

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

License: Other

Python 94.27% Shell 5.73%

aws-lambda-deploy's Introduction

aws-lambda-deploy

A collection of sample 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:

$ git clone https://github.com/awslabs/aws-lambda-deploy
$ cd aws-lambda-deploy
$ export 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.

# Rollout version 2 incrementally over 10 steps, with 120s between each step
$ aws 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.

$ export STATE_MACHINE_ARN=`aws cloudformation describe-stack-resources --stack-name aws-lambda-deploy-stack --logical-resource-id DeployStateMachine --output text | cut  -d$'\t' -f3`
$ aws stepfunctions start-execution --state-machine-arn $STATE_MACHINE_ARN --input '{
"function-name": "MyFunction",
"alias-name": "MyAlias",
"new-version": "2",
"steps": 10,
"interval": 120,
"type": "linear"}'

aws-lambda-deploy's People

Contributors

rpgreen avatar teknogeek0 avatar

Watchers

Kathak Mridha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.