@mhlabs/lambda-traffic-hooks

1.0.3 • Public • Published

lambda-traffic-hooks

This library contains two deploy hooks for verifying your code deploy:

  • BeforeAllowTraffic - via lambda invoke
  • AfterAllowTraffic - via http-request

Scenario:

AWS Lambda and AWS CodeDeploy recently made it possible to automatically shift incoming traffic between two function versions based on a preconfigured rollout strategy. This new feature allows you to gradually shift traffic to the new function. If there are any issues with the new code, you can quickly rollback and control the impact to your application [1].

Prerequisites

Expected environment variables:

  • VersionToTest

To execute the SAM and CloudFormation deployment, you must have the following IAM permissions [2]:

  • codedeploy:PutLifecycleEventHookExecutionStatus
  • lambda:InvokeFunction
  • cloudformation:*
  • iam:create*

Usage

Define endpoints with expected status code:

const endpoints = require('./tests');

endpoints.add('/health', 200);
endpoints.add('/ping', 200);

module.exports = require('./hooks');

Register hooks to function:

Reference

https://aws.amazon.com/blogs/compute/implementing-safe-aws-lambda-deployments-with-aws-codedeploy/

/@mhlabs/lambda-traffic-hooks/

    Package Sidebar

    Install

    npm i @mhlabs/lambda-traffic-hooks

    Weekly Downloads

    2

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    10.8 kB

    Total Files

    8

    Last publish

    Collaborators

    • mhlabs