{"_id":"@cabiri/serverless-plugin-canary-deployments","_rev":"1-0b55fd398064f28f22d23f3d1e47262f","name":"@cabiri/serverless-plugin-canary-deployments","dist-tags":{"latest":"0.4.9"},"versions":{"0.4.9":{"name":"@cabiri/serverless-plugin-canary-deployments","engines":{"node":">=4.0"},"version":"0.4.9","description":"A Serverless plugin to implement canary deployment of Lambda functions","main":"serverless-plugin-canary-deployments.js","scripts":{"test":"npm run lint && NODE_ENV=test ./node_modules/mocha/bin/mocha $(find ./ -name '*.test.js' -not -path '.*/node_modules/*')","watch":"NODE_ENV=test ./node_modules/mocha/bin/mocha -w $(find ./ -name '*.test.js' -not -path '*/node_modules/*')","lint":"standard"},"author":{"name":"David García","email":"davidgf1987@gmail.com"},"contributors":[{"name":"Carlos Castellanos","email":"ccverak@gmail.com","url":"https://github.com/ccverak/"},{"name":"Kartikeya Verma","email":"kverma23@outlook.com","url":"https://github.com/kverma23/"}],"license":"ISC","repository":{"url":"git+https://github.com/davidgf/serverless-plugin-canary-deployments.git","type":"git"},"dependencies":{"flat":"^4.1.0","lodash":"^4.17.15","omit-empty":"^0.4.1"},"devDependencies":{"chai":"^4.2.0","get-installed-path":"^4.0.8","husky":"^3.0.1","mocha":"^5.2.0","serverless":"^1.59.0","standard":"*"},"peerDependencies":{"serverless":">= 1.26.0"},"keywords":["aws","lambda","serverless","canary","gradual","deployments"],"husky":{"hooks":{"pre-push":"npm test"}},"standard":{"globals":["describe","context","it","before","after","beforeEach","afterEach"]},"gitHead":"27e66579c6f79cd7cbf1a9419ed3858c40309a19","bugs":{"url":"https://github.com/davidgf/serverless-plugin-canary-deployments/issues"},"homepage":"https://github.com/davidgf/serverless-plugin-canary-deployments#readme","_id":"@cabiri/serverless-plugin-canary-deployments@0.4.9","_nodeVersion":"12.14.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-VKbwgOx2caC5Rr+cHkIpeWE/vXaRRXAQhnjOFqt2lAnRGAAvBT4tWzb1HwCIgO7U6VUDyNsy5msyTvKOhLB9gw==","shasum":"f060c16bfba32c1b3521c9ac719b8986095e343c","tarball":"https://registry.npmjs.org/@cabiri/serverless-plugin-canary-deployments/-/serverless-plugin-canary-deployments-0.4.9.tgz","fileCount":73,"unpackedSize":431861,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeKwpTCRA9TVsSAnZWagAAN+IP/1aF4KgnHrbQw7ReHgiz\nuhWSeRFsrgKa5pGwY+7eSu54NIubCUraKbLhMfcfAOCfxhdNxEy05TzWNg65\npXUUyXn1q18UXU8bQ+qT/7E9AGSvDYGlT8qLAiFoHXZzmEOzD5cBopVO2usd\nUdiUzHcC1l6gyCw5yndhRMcSXtqRZ3NOS8Dk4UgHKXdXFnfDiGPPoyTa22NJ\nv6opUKjKTAaqg86KeuTF3TSvogfy3M0FLSS/d1nGc2N+VllJv1S6wUzizmLV\n5TJE/RCy/f/xtGh7M9rHkzoN54iqaZPmuwoI2qLcg/J/eCie9Qffh6HdVRU9\nfFAdKCDXxITDr/homDsu44yoidJTMBVgiWJFXhEZPzn3yFP+xtgS9dSOkQ0I\nQTaFCOhFhj9IKt5O75PiFK5tA59ZJqeX/tkpiiEzGGos0rryddLxw4tvlOU+\nXmZnGY1Pu+l4C5cxrXqIazVljlvb/FohOLVN9rP+L7A3j5Nz5clhW5cRMQTa\nqeqEbQNGvE5jflJEcFkp8P+GoaBLmdgcDW7QILX2MrfCAHFcoPjseIKBnoAE\nVilurah5Kl/rznDKsU/ZP70TBK+nzvKo/L6aM8TUvRwXo0lxB6tWZWQyLt47\nOhixqtLH18isK27MbRuXkXyx22Nv1Q124ba29fR77ciVf/nxoLghzJuziOBk\nDiHd\r\n=eZ/g\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCXsdl5912NT5qE3+Kmc5l4uVKpXNnA06b/uGbrAaAsnwIgJ3N7ta/L10Y4nI2kDAqVph/cDxAdDHfabBdH3g2fAes="}]},"maintainers":[{"name":"kamaz","email":"kamaz@xsimple.org"}],"_npmUser":{"name":"kamaz","email":"kamaz@xsimple.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/serverless-plugin-canary-deployments_0.4.9_1579878994522_0.3435309669871143"},"_hasShrinkwrap":false}},"time":{"created":"2020-01-24T15:16:34.262Z","0.4.9":"2020-01-24T15:16:34.681Z","modified":"2022-04-04T21:28:08.528Z"},"maintainers":[{"name":"kamaz","email":"kamaz@xsimple.org"}],"description":"A Serverless plugin to implement canary deployment of Lambda functions","homepage":"https://github.com/davidgf/serverless-plugin-canary-deployments#readme","keywords":["aws","lambda","serverless","canary","gradual","deployments"],"repository":{"url":"git+https://github.com/davidgf/serverless-plugin-canary-deployments.git","type":"git"},"contributors":[{"name":"Carlos Castellanos","email":"ccverak@gmail.com","url":"https://github.com/ccverak/"},{"name":"Kartikeya Verma","email":"kverma23@outlook.com","url":"https://github.com/kverma23/"}],"author":{"name":"David García","email":"davidgf1987@gmail.com"},"bugs":{"url":"https://github.com/davidgf/serverless-plugin-canary-deployments/issues"},"license":"ISC","readme":"[![npm version](https://badge.fury.io/js/serverless-plugin-canary-deployments.svg)](https://badge.fury.io/js/serverless-plugin-canary-deployments)\n\n# Serverless Plugin Canary Deployments\n\nA Serverless plugin to implement canary deployments of Lambda functions, making use of the [traffic shifting feature](https://docs.aws.amazon.com/lambda/latest/dg/lambda-traffic-shifting-using-aliases.html) in combination with [AWS CodeDeploy](https://docs.aws.amazon.com/lambda/latest/dg/automating-updates-to-serverless-apps.html)\n\n## Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Configuration](#configuration)\n- [How it works](#how)\n- [Limitations](#limitations)\n- [License](#license)\n\n## <a name=\"installation\"></a>Installation\n\n`npm i --save-dev serverless-plugin-canary-deployments`\n\n## <a name=\"usage\"></a>Usage\n\nTo enable gradual deployments for Lambda functions, your `serverless.yml` should look like this:\n\n```yaml\nservice: canary-deployments\nprovider:\n  name: aws\n  runtime: nodejs6.10\n  iamRoleStatements:\n    - Effect: Allow\n      Action:\n        - codedeploy:*\n      Resource:\n        - \"*\"\n\nplugins:\n  - serverless-plugin-canary-deployments\n\nfunctions:\n  hello:\n    handler: handler.hello\n    events:\n      - http: GET hello\n    deploymentSettings:\n      type: Linear10PercentEvery1Minute\n      alias: Live\n      preTrafficHook: preHook\n      postTrafficHook: postHook\n      alarms:\n        - FooAlarm          # When a string is provided, it expects the alarm Logical ID\n        - name: BarAlarm    # When an object is provided, it expects the alarm name in the name property\n\n  preHook:\n    handler: hooks.pre\n  postHook:\n    handler: hooks.post\n```\n\nYou can see a working example in the [example folder](./example/).\n\n## <a name=\"configuration\"></a>Configuration\n\n* `type`: (required) defines how the traffic will be shifted between Lambda function versions. It must be one of the following:\n  - `Canary10Percent5Minutes`: shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed five minutes later.\n  - `Canary10Percent10Minutes`: shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed 10 minutes later.\n  - `Canary10Percent15Minutes`: shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed 15 minutes later.\n  - `Canary10Percent30Minutes`: shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed 30 minutes later.\n  - `Linear10PercentEvery1Minute`: shifts 10 percent of traffic every minute until all traffic is shifted.\n  - `Linear10PercentEvery2Minutes`: shifts 10 percent of traffic every two minutes until all traffic is shifted.\n  - `Linear10PercentEvery3Minutes`: shifts 10 percent of traffic every three minutes until all traffic is shifted.\n  - `Linear10PercentEvery10Minutes`: shifts 10 percent of traffic every 10 minutes until all traffic is shifted.\n  - `AllAtOnce`: shifts all the traffic to the new version, useful when you only need to execute the validation hooks.\n* `alias`: (required) name that will be used to create the Lambda function alias.\n* `preTrafficHook`: (optional) validation Lambda function that runs before traffic shifting. It must use te CodeDeploy SDK to notify about this step's success or failure (more info [here](https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html)).\n* `postTrafficHook`: (optional) validation Lambda function that runs after traffic shifting. It must use te CodeDeploy SDK to notify about this step's success or failure (more info [here](https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html))\n* `alarms`: (optional) list of CloudWatch alarms. If any of them is triggered during the deployment, the associated Lambda function will automatically roll back to the previous version.\n* `triggerConfigurations`: (optional) list of CodeDeploy Triggers. See more details in the [CodeDeploy TriggerConfiguration Documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codedeploy-deploymentgroup-triggerconfig.html), or [this CodeDeploy notifications guide](https://docs.aws.amazon.com/codedeploy/latest/userguide/monitoring-sns-event-notifications-create-trigger.html) for example uses\n\n### Default configurations\n\nYou can set default values for all functions in a top-level custom deploymentSettings section.  E.g.:\n\n```yaml\ncustom:\n  deploymentSettings:\n    codeDeployRole: some_arn_value\n    stages:\n      - dev\n      - prod\n\nfunctions:\n  ...\n```\n\nSome values are only available as top-level configurations.  They are:\n\n* `codeDeployRole`: (optional) an ARN specifying an existing IAM role for CodeDeploy.  If absent, one will be created for you.  See the [codeDeploy policy](./example-code-deploy-policy.json) for an example of what is needed.\n* `stages`: (optional) list of stages where you want to deploy your functions gradually. If not present, it assumes that are all of them.\n\n## <a name=\"how\"></a>How it works\n\nThe plugin relies on the [AWS Lambda traffic shifting feature](https://docs.aws.amazon.com/lambda/latest/dg/lambda-traffic-shifting-using-aliases.html) to balance traffic between versions and [AWS CodeDeploy](https://docs.aws.amazon.com/lambda/latest/dg/automating-updates-to-serverless-apps.html) to automatically update its weight. It modifies the `CloudFormation` template generated by [Serverless](https://github.com/serverless/serverless), so that:\n\n1. It creates a Lambda function Alias for each function with deployment settings.\n2. It creates a CodeDeploy Application and adds a [CodeDeploy DeploymentGroup](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html) per Lambda function, according to the specified settings.\n3. It modifies events that trigger Lambda functions, so that they invoke the newly created alias.\n\n## <a name=\"limitations\"></a>Limitations\n\nFor now, the plugin only works with Lambda functions invoked by\n\n* API Gateway\n* Stream based (such as the triggered by Kinesis, DynamoDB Streams or SQS)\n* SNS based events\n* S3 events\n* CloudWatch Scheduled events\n* CloudWatch Logs\n* IoT rules\n\n[More events](https://serverless.com/framework/docs/providers/aws/events/) will be added soon.\n\n## <a name=\"license\"></a>License\n\nISC © [David García](https://github.com/davidgf)\n","readmeFilename":"README.md"}