From ad38cd86f053309fe12208cb7845db06606508ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Garc=C3=ADa?= Date: Sat, 24 Feb 2018 18:58:56 +0100 Subject: [PATCH] Enable canary deployment capabilities for Lambda functions triggered by API Gateway --- .editorconfig | 9 + .eslintrc | 15 + .gitignore | 1 + LICENSE | 15 + README.md | 77 ++ cf-computed-example.json | 268 ++++ lib/CfTemplateGenerators/ApiGateway.js | 22 + lib/CfTemplateGenerators/ApiGateway.test.js | 46 + lib/CfTemplateGenerators/CodeDeploy.js | 56 + lib/CfTemplateGenerators/CodeDeploy.test.js | 82 ++ lib/CfTemplateGenerators/Iam.js | 27 + lib/CfTemplateGenerators/Iam.test.js | 30 + lib/CfTemplateGenerators/Lambda.js | 42 + lib/CfTemplateGenerators/Lambda.test.js | 81 ++ lib/CfTemplateGenerators/index.js | 9 + package-lock.json | 1333 +++++++++++++++++++ package.json | 27 + sam-source-example.yaml | 27 + serverless-plugin-canary-deployments.js | 175 +++ 19 files changed, 2342 insertions(+) create mode 100644 .editorconfig create mode 100644 .eslintrc create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 cf-computed-example.json create mode 100644 lib/CfTemplateGenerators/ApiGateway.js create mode 100644 lib/CfTemplateGenerators/ApiGateway.test.js create mode 100644 lib/CfTemplateGenerators/CodeDeploy.js create mode 100644 lib/CfTemplateGenerators/CodeDeploy.test.js create mode 100644 lib/CfTemplateGenerators/Iam.js create mode 100644 lib/CfTemplateGenerators/Iam.test.js create mode 100644 lib/CfTemplateGenerators/Lambda.js create mode 100644 lib/CfTemplateGenerators/Lambda.test.js create mode 100644 lib/CfTemplateGenerators/index.js create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 sam-source-example.yaml create mode 100644 serverless-plugin-canary-deployments.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c6c8b36 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..96ad0f2 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,15 @@ +{ + "env": { + "mocha": true + }, + "extends": "airbnb", + "rules": { + "comma-dangle": [ + 2, + "never" + ], + "array-bracket-spacing": 0, + "object-curly-spacing": 0, + "object-curly-newline": 0 + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fb39ff3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2018, David García Fernández + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b2f151c --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +# Serverless Plugin Canary Deployments + +A 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) + +## Installation + +`npm i --save-dev serverless-plugin-canary-deployments` + +## Usage + +To enable gradual deployments for Lambda functions, your `serverless.yml` should look like this: + +```yaml +service: canary-deployments +provider: + name: aws + runtime: nodejs6.10 + iamRoleStatements: + - Effect: Allow + Action: + - codedeploy:* + Resource: + - "*" + +plugins: + - serverless-plugin-canary-deployments + +functions: + hello: + handler: handler.hello + events: + - http: GET hello + deploymentSettings: + type: Linear10PercentEvery1Minute + alias: Live + preTrafficHook: preHook + postTrafficHook: postHook + alarms: + - FooAlarm + - BarAlarm + preHook: + handler: hooks.pre + postHook: + handler: hooks.post +``` + +## Configuration + +* `type`: (required) defines how the traffic will be shifted between Lambda function versions. It must be one of the following: + - `Canary10Percent5Minutes`: shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed five minutes later. + - `Canary10Percent10Minutes`: shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed 10 minutes later. + - `Canary10Percent15Minutes`: shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed 15 minutes later. + - `Canary10Percent30Minutes`: shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed 30 minutes later. + - `Linear10PercentEvery1Minute`: shifts 10 percent of traffic every minute until all traffic is shifted. + - `Linear10PercentEvery2Minutes`: shifts 10 percent of traffic every two minutes until all traffic is shifted. + - `Linear10PercentEvery3Minutes`: shifts 10 percent of traffic every three minutes until all traffic is shifted. + - `Linear10PercentEvery10Minutes`: shifts 10 percent of traffic every 30 minutes until all traffic is shifted. +* `alias`: (required) name that will be used to create the Lambda function alias. +* `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)). +* `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)) +* `alarms`: (optional) list of CloudWatch alarms. If any of them is triggered duringt the deployment, the associated Lambda function will automatically roll back to the previous version. + +## How it works + +The 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: + +1. It creates a Lambda function Alias for each function with deployment settings. +2. 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. +3. It modifies events that trigger Lambda functions, so that they invoke the newly created alias. + +## Limitations + +For now, the plugin only works with Lambda functions invoked by API Gateway. More events will be added soon. + +## License + +ISC © [David García](https://github.com/davidgf) diff --git a/cf-computed-example.json b/cf-computed-example.json new file mode 100644 index 0000000..09d9acb --- /dev/null +++ b/cf-computed-example.json @@ -0,0 +1,268 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Resources": { + "MyFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "aws-nodejs-dev-serverlessdeploymentbucket-14iyutt06erm7", + "S3Key": "serverless/aws-nodejs/dev/1515768309333-2018-01-12T14:45:09.333Z/aws-nodejs.zip" + }, + "Handler": "handler.hello", + "Role": { + "Fn::GetAtt": [ + "MyFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs6.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "CodeDeployServiceRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSCodeDeployRoleForLambda" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "codedeploy.amazonaws.com" + ] + } + } + ] + } + } + }, + "MyFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "MyFunctionVersione57c0000de": { + "DeletionPolicy": "Retain", + "Type": "AWS::Lambda::Version", + "Properties": { + "FunctionName": { + "Ref": "MyFunction" + } + } + }, + "MyOtherFunctionVersione57c0000de": { + "DeletionPolicy": "Retain", + "Type": "AWS::Lambda::Version", + "Properties": { + "FunctionName": { + "Ref": "MyOtherFunction" + } + } + }, + "MyFunctionDeploymentGroup": { + "Type": "AWS::CodeDeploy::DeploymentGroup", + "Properties": { + "ApplicationName": { + "Ref": "ServerlessDeploymentApplication" + }, + "AutoRollbackConfiguration": { + "Enabled": true, + "Events": [ + "DEPLOYMENT_FAILURE", + "DEPLOYMENT_STOP_ON_ALARM", + "DEPLOYMENT_STOP_ON_REQUEST" + ] + }, + "ServiceRoleArn": { + "Fn::GetAtt": [ + "CodeDeployServiceRole", + "Arn" + ] + }, + "DeploymentConfigName": { + "Fn::Sub": [ + "CodeDeployDefault.Lambda${ConfigName}", + { + "ConfigName": "Linear10PercentEvery1Minute" + } + ] + }, + "DeploymentStyle": { + "DeploymentType": "BLUE_GREEN", + "DeploymentOption": "WITH_TRAFFIC_CONTROL" + } + } + }, + "MyFunctionAliaslive": { + "Type": "AWS::Lambda::Alias", + "UpdatePolicy": { + "CodeDeployLambdaAliasUpdate": { + "ApplicationName": { + "Ref": "ServerlessDeploymentApplication" + }, + "AfterAllowTrafficHook": { + "Ref": "MyOtherFunction" + }, + "DeploymentGroupName": { + "Ref": "MyFunctionDeploymentGroup" + } + } + }, + "Properties": { + "FunctionVersion": { + "Fn::GetAtt": [ + "MyFunctionVersione57c0000de", + "Version" + ] + }, + "FunctionName": { + "Ref": "MyFunction" + }, + "Name": "live" + } + }, + "MyOtherFunctionDeploymentGroup": { + "Type": "AWS::CodeDeploy::DeploymentGroup", + "Properties": { + "ApplicationName": { + "Ref": "ServerlessDeploymentApplication" + }, + "AutoRollbackConfiguration": { + "Enabled": true, + "Events": [ + "DEPLOYMENT_FAILURE", + "DEPLOYMENT_STOP_ON_ALARM", + "DEPLOYMENT_STOP_ON_REQUEST" + ] + }, + "ServiceRoleArn": { + "Fn::GetAtt": [ + "CodeDeployServiceRole", + "Arn" + ] + }, + "DeploymentConfigName": { + "Fn::Sub": [ + "CodeDeployDefault.Lambda${ConfigName}", + { + "ConfigName": "Canary10Percent30Minutes" + } + ] + }, + "DeploymentStyle": { + "DeploymentType": "BLUE_GREEN", + "DeploymentOption": "WITH_TRAFFIC_CONTROL" + } + } + }, + "MyOtherFunctionAliaspublic": { + "Type": "AWS::Lambda::Alias", + "UpdatePolicy": { + "CodeDeployLambdaAliasUpdate": { + "ApplicationName": { + "Ref": "ServerlessDeploymentApplication" + }, + "DeploymentGroupName": { + "Ref": "MyOtherFunctionDeploymentGroup" + } + } + }, + "Properties": { + "FunctionVersion": { + "Fn::GetAtt": [ + "MyOtherFunctionVersione57c0000de", + "Version" + ] + }, + "FunctionName": { + "Ref": "MyOtherFunction" + }, + "Name": "public" + } + }, + "MyOtherFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "ServerlessDeploymentApplication": { + "Type": "AWS::CodeDeploy::Application", + "Properties": { + "ComputePlatform": "Lambda" + } + }, + "MyOtherFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "aws-nodejs-dev-serverlessdeploymentbucket-14iyutt06erm7", + "S3Key": "serverless/aws-nodejs/dev/1515768309333-2018-01-12T14:45:09.333Z/aws-nodejs.zip" + }, + "Handler": "handler.hello", + "Role": { + "Fn::GetAtt": [ + "MyOtherFunctionRole", + "Arn" + ] + }, + "Runtime": "nodejs6.10", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + } + } +} diff --git a/lib/CfTemplateGenerators/ApiGateway.js b/lib/CfTemplateGenerators/ApiGateway.js new file mode 100644 index 0000000..fb08303 --- /dev/null +++ b/lib/CfTemplateGenerators/ApiGateway.js @@ -0,0 +1,22 @@ +const _ = require('lodash/fp'); + +function buildUriForAlias(functionAlias) { + const aliasArn = [ + 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${', + functionAlias, + '}/invocations' + ].join(''); + return { 'Fn::Sub': aliasArn }; +} + +function replaceMethodUriWithAlias(apiGatewayMethod, functionAlias) { + const aliasUri = buildUriForAlias(functionAlias); + const newMethod = _.set('Properties.Integration.Uri', aliasUri, apiGatewayMethod); + return newMethod; +} + +const ApiGateway = { + replaceMethodUriWithAlias +}; + +module.exports = ApiGateway; diff --git a/lib/CfTemplateGenerators/ApiGateway.test.js b/lib/CfTemplateGenerators/ApiGateway.test.js new file mode 100644 index 0000000..370ed7c --- /dev/null +++ b/lib/CfTemplateGenerators/ApiGateway.test.js @@ -0,0 +1,46 @@ +const { expect } = require('chai'); +const _ = require('lodash/fp'); +const ApiGateway = require('./ApiGateway'); + +describe('ApiGateway', () => { + const apiGatewayMethod = { + Type: 'AWS::ApiGateway::Method', + Properties: { + HttpMethod: 'GET', + ResourceId: { Ref: 'ApiGatewayResourceId' }, + RestApiId: { Ref: 'ApiGatewayRestApi' }, + Integration: { + IntegrationHttpMethod: 'POST', + Type: 'AWS_PROXY', + Uri: { + 'Fn::Join': [ + '', + [ + 'arn:aws:apigateway:', + { Ref: 'AWS::Region' }, + ':lambda:path/2015-03-31/functions/', + { 'Fn:GetAtt': [ 'HelloLambdaFunction', 'Arn' ] }, + '/invocations' + ] + ] + } + }, + MethodResponses: [] + } + }; + + describe('.replaceMethodUriWithAlias', () => { + it('replaces the method URI with a function alias ARN', () => { + const functionAlias = 'TheFunctionAlias'; + const uriWithAwsVariables = [ + 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${', + functionAlias, + '}/invocations' + ].join(''); + const uri = { 'Fn::Sub': uriWithAwsVariables }; + const expected = _.set('Properties.Integration.Uri', uri, apiGatewayMethod); + const actual = ApiGateway.replaceMethodUriWithAlias(apiGatewayMethod, functionAlias); + expect(actual).to.deep.equal(expected); + }); + }); +}); diff --git a/lib/CfTemplateGenerators/CodeDeploy.js b/lib/CfTemplateGenerators/CodeDeploy.js new file mode 100644 index 0000000..f91718c --- /dev/null +++ b/lib/CfTemplateGenerators/CodeDeploy.js @@ -0,0 +1,56 @@ +function buildApplication() { + return { + Type: 'AWS::CodeDeploy::Application', + Properties: { ComputePlatform: 'Lambda' } + }; +} + +function buildFnDeploymentGroup({ codeDeployAppName, deploymentSettings = {} }) { + const deploymentGroup = { + Type: 'AWS::CodeDeploy::DeploymentGroup', + Properties: { + ApplicationName: { + Ref: codeDeployAppName + }, + AutoRollbackConfiguration: { + Enabled: true, + Events: [ + 'DEPLOYMENT_FAILURE', + 'DEPLOYMENT_STOP_ON_ALARM', + 'DEPLOYMENT_STOP_ON_REQUEST' + ] + }, + ServiceRoleArn: { + 'Fn::GetAtt': [ + 'CodeDeployServiceRole', + 'Arn' + ] + }, + DeploymentConfigName: { + 'Fn::Sub': [ + 'CodeDeployDefault.Lambda${ConfigName}', + { ConfigName: deploymentSettings.type } + ] + }, + DeploymentStyle: { + DeploymentType: 'BLUE_GREEN', + DeploymentOption: 'WITH_TRAFFIC_CONTROL' + } + } + }; + if (deploymentSettings.alarms) { + const alarmConfig = { + Alarms: deploymentSettings.alarms.map(a => ({ Name: { Ref: a } })), + Enabled: true + }; + Object.assign(deploymentGroup.Properties, { AlarmConfiguration: alarmConfig }); + } + return deploymentGroup; +} + +const CodeDeploy = { + buildApplication, + buildFnDeploymentGroup +}; + +module.exports = CodeDeploy; diff --git a/lib/CfTemplateGenerators/CodeDeploy.test.js b/lib/CfTemplateGenerators/CodeDeploy.test.js new file mode 100644 index 0000000..35ad190 --- /dev/null +++ b/lib/CfTemplateGenerators/CodeDeploy.test.js @@ -0,0 +1,82 @@ +const { expect } = require('chai'); +const _ = require('lodash/fp'); +const CodeDeploy = require('./CodeDeploy'); + +describe('CodeDeploy', () => { + describe('.buildApplication', () => { + it('generates a CodeDeploy::Application resouce', () => { + const expected = { + Type: 'AWS::CodeDeploy::Application', + Properties: { ComputePlatform: 'Lambda' } + }; + const actual = CodeDeploy.buildApplication(); + expect(actual).to.deep.equal(expected); + }); + }); + + describe('.buildFnDeploymentGroup', () => { + const codeDeployAppName = 'MyCDApp'; + const baseDeploymentGroup = { + Type: 'AWS::CodeDeploy::DeploymentGroup', + Properties: { + ApplicationName: { + Ref: '' + }, + AutoRollbackConfiguration: { + Enabled: true, + Events: [ + 'DEPLOYMENT_FAILURE', + 'DEPLOYMENT_STOP_ON_ALARM', + 'DEPLOYMENT_STOP_ON_REQUEST' + ] + }, + ServiceRoleArn: { + 'Fn::GetAtt': [ + 'CodeDeployServiceRole', + 'Arn' + ] + }, + DeploymentConfigName: { + 'Fn::Sub': [ + 'CodeDeployDefault.Lambda${ConfigName}', + { ConfigName: '' } + ] + }, + DeploymentStyle: { + DeploymentType: 'BLUE_GREEN', + DeploymentOption: 'WITH_TRAFFIC_CONTROL' + } + } + }; + + it('should generate a CodeDeploy::DeploymentGroup resouce for the provided function', () => { + const deploymentSettings = { + type: 'Linear10PercentEvery1Minute', + alarms: [ 'Alarm1', 'Alarm2' ] + }; + const expectedAlarms = { + Alarms: [ { Name: { Ref: 'Alarm1' } }, { Name: { Ref: 'Alarm2' } }], + Enabled: true + }; + const expected = _.pipe( + _.set('Properties.ApplicationName', { Ref: codeDeployAppName }), + _.set('Properties.AlarmConfiguration', expectedAlarms), + _.set('Properties.DeploymentConfigName.Fn::Sub[1].ConfigName', deploymentSettings.type) + )(baseDeploymentGroup); + const actual = CodeDeploy.buildFnDeploymentGroup({ codeDeployAppName, deploymentSettings }); + expect(actual).to.deep.equal(expected); + }); + + context('when no alarms were provided', () => { + it('should not include the AlarmConfiguration property', () => { + const deploymentSettings = { type: 'Linear10PercentEvery1Minute' }; + const expected = _.pipe( + _.set('Properties.ApplicationName', { Ref: codeDeployAppName }), + _.set('Properties.DeploymentConfigName.Fn::Sub[1].ConfigName', deploymentSettings.type) + )(baseDeploymentGroup); + const actual = CodeDeploy.buildFnDeploymentGroup({ codeDeployAppName, deploymentSettings }); + expect(actual).to.deep.equal(expected); + }); + }); + }); +}); diff --git a/lib/CfTemplateGenerators/Iam.js b/lib/CfTemplateGenerators/Iam.js new file mode 100644 index 0000000..f99680d --- /dev/null +++ b/lib/CfTemplateGenerators/Iam.js @@ -0,0 +1,27 @@ +function buildCodeDeployRole() { + return { + Type: 'AWS::IAM::Role', + Properties: { + ManagedPolicyArns: [ + 'arn:aws:iam::aws:policy/service-role/AWSCodeDeployRoleForLambda', + 'arn:aws:iam::aws:policy/AWSLambdaFullAccess' + ], + AssumeRolePolicyDocument: { + Version: '2012-10-17', + Statement: [ + { + Action: [ 'sts:AssumeRole' ], + Effect: 'Allow', + Principal: { Service: [ 'codedeploy.amazonaws.com' ] } + } + ] + } + } + }; +} + +const Iam = { + buildCodeDeployRole +}; + +module.exports = Iam; diff --git a/lib/CfTemplateGenerators/Iam.test.js b/lib/CfTemplateGenerators/Iam.test.js new file mode 100644 index 0000000..ed57a35 --- /dev/null +++ b/lib/CfTemplateGenerators/Iam.test.js @@ -0,0 +1,30 @@ +const { expect } = require('chai'); +const Iam = require('./Iam'); + +describe('Iam', () => { + describe('.buildCodeDeployRole', () => { + it('should generate a CodeDeploy::Application resouce', () => { + const expected = { + Type: 'AWS::IAM::Role', + Properties: { + ManagedPolicyArns: [ + 'arn:aws:iam::aws:policy/service-role/AWSCodeDeployRoleForLambda', + 'arn:aws:iam::aws:policy/AWSLambdaFullAccess' + ], + AssumeRolePolicyDocument: { + Version: '2012-10-17', + Statement: [ + { + Action: [ 'sts:AssumeRole' ], + Effect: 'Allow', + Principal: { Service: [ 'codedeploy.amazonaws.com' ] } + } + ] + } + } + }; + const actual = Iam.buildCodeDeployRole(); + expect(actual).to.deep.equal(expected); + }); + }); +}); diff --git a/lib/CfTemplateGenerators/Lambda.js b/lib/CfTemplateGenerators/Lambda.js new file mode 100644 index 0000000..a67b00c --- /dev/null +++ b/lib/CfTemplateGenerators/Lambda.js @@ -0,0 +1,42 @@ +const _ = require('lodash/fp'); +const omitEmpty = require('omit-empty'); + +function buildUpdatePolicy({ codeDeployApp, deploymentGroup, afterHook, beforeHook }) { + const updatePolicy = { + CodeDeployLambdaAliasUpdate: { + ApplicationName: { Ref: codeDeployApp }, + AfterAllowTrafficHook: { Ref: afterHook }, + BeforeAllowTrafficHook: { Ref: beforeHook }, + DeploymentGroupName: { Ref: deploymentGroup } + } + }; + return omitEmpty({ UpdatePolicy: updatePolicy }); +} + +function buildAlias({ alias, functionName, functionVersion, trafficShiftingSettings }) { + const lambdaAlias = { + Type: 'AWS::Lambda::Alias', + Properties: { + FunctionVersion: { 'Fn::GetAtt': [ functionVersion, 'Version' ] }, + FunctionName: { Ref: functionName }, + Name: alias + } + }; + if (trafficShiftingSettings) { + const updatePolicy = buildUpdatePolicy(trafficShiftingSettings); + Object.assign(lambdaAlias, updatePolicy); + } + return lambdaAlias; +} + +function replacePermissionFunctionWithAlias(lambdaPermission, funcitonAlias) { + const newPermission = _.set('Properties.FunctionName', { Ref: funcitonAlias }, lambdaPermission); + return newPermission; +} + +const Lambda = { + buildAlias, + replacePermissionFunctionWithAlias +}; + +module.exports = Lambda; diff --git a/lib/CfTemplateGenerators/Lambda.test.js b/lib/CfTemplateGenerators/Lambda.test.js new file mode 100644 index 0000000..b19008e --- /dev/null +++ b/lib/CfTemplateGenerators/Lambda.test.js @@ -0,0 +1,81 @@ +const { expect } = require('chai'); +const _ = require('lodash/fp'); +const Lambda = require('./Lambda'); + +describe('Lambda', () => { + describe('.buildAlias', () => { + const functionName = 'MyFunctionName'; + const functionVersion = 'MyFunctionVersion'; + const alias = 'live'; + const baseAlias = { + Type: 'AWS::Lambda::Alias', + Properties: { + FunctionVersion: { 'Fn::GetAtt': [ functionVersion, 'Version' ] }, + FunctionName: { Ref: functionName }, + Name: alias + } + }; + + it('should generate a AWS::Lambda::Alias resouce', () => { + const expected = baseAlias; + const actual = Lambda.buildAlias({ alias, functionName, functionVersion }); + expect(actual).to.deep.equal(expected); + }); + + context('when traffic shifting settings were provided', () => { + it('should include the UpdatePolicy', () => { + const trafficShiftingSettings = { + codeDeployApp: 'CodeDeployAppName', + deploymentGroup: 'DeploymentGroup', + beforeHook: 'BeforeHookLambdaFn', + afterHook: 'AfterHookLambdaFn' + }; + const expected = { + UpdatePolicy: { + CodeDeployLambdaAliasUpdate: { + ApplicationName: { Ref: trafficShiftingSettings.codeDeployApp }, + AfterAllowTrafficHook: { Ref: trafficShiftingSettings.afterHook }, + BeforeAllowTrafficHook: { Ref: trafficShiftingSettings.beforeHook }, + DeploymentGroupName: { Ref: trafficShiftingSettings.deploymentGroup } + } + } + }; + const actual = Lambda.buildAlias({ alias, functionName, functionVersion, trafficShiftingSettings }); + expect(actual).to.deep.include(expected); + }); + }); + }); + + describe('.replacePermissionFunctionWithAlias', () => { + const lambdaPermission = { + Type: 'AWS::Lambda::Permission', + Properties: { + FunctionName: { 'Fn::GetAtt': ['HelloLambdaFunctionAliasLive', 'Arn'] }, + Action: 'lambda:InvokeFunction', + Principal: 'apigateway.amazonaws.com', + SourceArn: { + 'Fn::Join': [ + '', + [ + 'arn:aws:execute-api:', + { Ref: 'AWS::Region' }, + ':', + { Ref: 'AWS::AccountId' }, + ':', + { Ref: 'ApiGatewayRestApi' }, + '/*/*' + ] + ] + } + } + }; + + it('replaces the permission\'s function for an alias', () => { + const functionAlias = 'TheFunctionAlias'; + const permissionFunctionWithAlias = { Ref: functionAlias }; + const expected = _.set('Properties.FunctionName', permissionFunctionWithAlias, lambdaPermission); + const actual = Lambda.replacePermissionFunctionWithAlias(lambdaPermission, functionAlias); + expect(actual).to.deep.equal(expected); + }); + }); +}); diff --git a/lib/CfTemplateGenerators/index.js b/lib/CfTemplateGenerators/index.js new file mode 100644 index 0000000..e6ba62c --- /dev/null +++ b/lib/CfTemplateGenerators/index.js @@ -0,0 +1,9 @@ +const CodeDeploy = require('./CodeDeploy'); +const Iam = require('./Iam'); +const Lambda = require('./Lambda'); +const ApiGateway = require('./ApiGateway'); + +module.exports.codeDeploy = CodeDeploy; +module.exports.iam = Iam; +module.exports.lambda = Lambda; +module.exports.apiGateway = ApiGateway; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..ab07fc5 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1333 @@ +{ + "name": "serverless-aws-canary-deployments", + "version": "0.1.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "acorn": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz", + "integrity": "sha512-XLmq3H/BVvW6/GbxKryGxWORz1ebilSsUDlyC27bXhWGWAZWkGwS6FLHjOlwFXNFoWFQEO/Df4u0YYd0K3BQgQ==", + "dev": true + }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "dev": true, + "requires": { + "acorn": "3.3.0" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + } + } + }, + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "dev": true, + "requires": { + "co": "4.6.0", + "fast-deep-equal": "1.0.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" + } + }, + "ajv-keywords": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", + "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", + "dev": true + }, + "ansi-escapes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz", + "integrity": "sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==", + "dev": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "1.0.3" + } + }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "1.0.3" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + }, + "dependencies": { + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "dev": true + }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "dev": true, + "requires": { + "callsites": "0.2.0" + } + }, + "callsites": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "dev": true + }, + "chai": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", + "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", + "dev": true, + "requires": { + "assertion-error": "1.1.0", + "check-error": "1.0.2", + "deep-eql": "3.0.1", + "get-func-name": "2.0.0", + "pathval": "1.1.0", + "type-detect": "4.0.7" + } + }, + "chalk": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.1.tgz", + "integrity": "sha512-QUU4ofkDoMIVO7hcx1iPTISs88wsO8jA92RQIm4JAwZvFGGAV2hSAA1NX7oVj2Ej2Q6NDTcRDjPTFrMCRZoJ6g==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "5.2.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.2.0.tgz", + "integrity": "sha512-F39vS48la4YvTZUPVeTqsjsFNrvcMwrV3RLZINsmHo+7djCvuUzSIeXOnZ5hmjef4bajL1dNccN+tg5XAliO5Q==", + "dev": true, + "requires": { + "has-flag": "3.0.0" + } + } + } + }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", + "dev": true + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "dev": true + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true + }, + "color-convert": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.4", + "typedarray": "0.0.6" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "4.1.1", + "shebang-command": "1.2.0", + "which": "1.3.0" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "4.0.7" + } + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "del": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "dev": true, + "requires": { + "globby": "5.0.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.0", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "rimraf": "2.6.2" + } + }, + "diff": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", + "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", + "dev": true + }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "2.0.2" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "eslint": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.18.1.tgz", + "integrity": "sha512-gPSfpSRCHre1GLxGmO68tZNxOlL2y7xBd95VcLD+Eo4S2js31YoMum3CAQIOaxY24hqYOMksMvW38xuuWKQTgw==", + "dev": true, + "requires": { + "ajv": "5.5.2", + "babel-code-frame": "6.26.0", + "chalk": "2.3.1", + "concat-stream": "1.6.0", + "cross-spawn": "5.1.0", + "debug": "3.1.0", + "doctrine": "2.1.0", + "eslint-scope": "3.7.1", + "eslint-visitor-keys": "1.0.0", + "espree": "3.5.3", + "esquery": "1.0.0", + "esutils": "2.0.2", + "file-entry-cache": "2.0.0", + "functional-red-black-tree": "1.0.1", + "glob": "7.1.2", + "globals": "11.3.0", + "ignore": "3.3.7", + "imurmurhash": "0.1.4", + "inquirer": "3.3.0", + "is-resolvable": "1.1.0", + "js-yaml": "3.10.0", + "json-stable-stringify-without-jsonify": "1.0.1", + "levn": "0.3.0", + "lodash": "4.17.4", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "natural-compare": "1.4.0", + "optionator": "0.8.2", + "path-is-inside": "1.0.2", + "pluralize": "7.0.0", + "progress": "2.0.0", + "require-uncached": "1.0.3", + "semver": "5.5.0", + "strip-ansi": "4.0.0", + "strip-json-comments": "2.0.1", + "table": "4.0.2", + "text-table": "0.2.0" + } + }, + "eslint-config-airbnb": { + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb/-/eslint-config-airbnb-16.1.0.tgz", + "integrity": "sha512-zLyOhVWhzB/jwbz7IPSbkUuj7X2ox4PHXTcZkEmDqTvd0baJmJyuxlFPDlZOE/Y5bC+HQRaEkT3FoHo9wIdRiw==", + "dev": true, + "requires": { + "eslint-config-airbnb-base": "12.1.0" + } + }, + "eslint-config-airbnb-base": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-12.1.0.tgz", + "integrity": "sha512-/vjm0Px5ZCpmJqnjIzcFb9TKZrKWz0gnuG/7Gfkt0Db1ELJR51xkZth+t14rYdqWgX836XbuxtArbIHlVhbLBA==", + "dev": true, + "requires": { + "eslint-restricted-globals": "0.1.1" + } + }, + "eslint-restricted-globals": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz", + "integrity": "sha1-NfDVy8ZMLj7WLpO0saevBbp+1Nc=", + "dev": true + }, + "eslint-scope": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", + "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", + "dev": true, + "requires": { + "esrecurse": "4.2.0", + "estraverse": "4.2.0" + } + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", + "dev": true + }, + "espree": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.3.tgz", + "integrity": "sha512-Zy3tAJDORxQZLl2baguiRU1syPERAIg0L+JB2MWorORgTu/CplzvxS9WWA7Xh4+Q+eOQihNs/1o1Xep8cvCxWQ==", + "dev": true, + "requires": { + "acorn": "5.4.1", + "acorn-jsx": "3.0.1" + } + }, + "esprima": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", + "dev": true + }, + "esquery": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz", + "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", + "dev": true, + "requires": { + "estraverse": "4.2.0" + } + }, + "esrecurse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.0.tgz", + "integrity": "sha1-+pVo2Y04I/mkHZHpAtyrnqblsWM=", + "dev": true, + "requires": { + "estraverse": "4.2.0", + "object-assign": "4.1.1" + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "external-editor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", + "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==", + "dev": true, + "requires": { + "chardet": "0.4.2", + "iconv-lite": "0.4.19", + "tmp": "0.0.33" + } + }, + "fast-deep-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", + "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5" + } + }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "dev": true, + "requires": { + "flat-cache": "1.3.0", + "object-assign": "4.1.1" + } + }, + "flat": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.0.0.tgz", + "integrity": "sha512-ji/WMv2jdsE+LaznpkIF9Haax0sdpTBozrz/Dtg4qSRMfbs8oVg4ypJunIRYPiMLvH/ed6OflXbnbTIKJhtgeg==", + "requires": { + "is-buffer": "1.1.6" + } + }, + "flat-cache": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", + "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", + "dev": true, + "requires": { + "circular-json": "0.3.3", + "del": "2.2.2", + "graceful-fs": "4.1.11", + "write": "0.2.1" + } + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" + }, + "for-own": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", + "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", + "requires": { + "for-in": "1.0.2" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "globals": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.3.0.tgz", + "integrity": "sha512-kkpcKNlmQan9Z5ZmgqKH/SMbSmjxQ7QjyNqfXVc8VJcoBV2UEg+sxQD15GQofGRh2hfpwUb70VC31DR7Rq5Hdw==", + "dev": true + }, + "globby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "dev": true, + "requires": { + "array-union": "1.0.2", + "arrify": "1.0.1", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "growl": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", + "dev": true + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=" + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", + "dev": true + }, + "ignore": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "inquirer": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", + "dev": true, + "requires": { + "ansi-escapes": "3.0.0", + "chalk": "2.3.1", + "cli-cursor": "2.1.0", + "cli-width": "2.2.0", + "external-editor": "2.1.0", + "figures": "2.0.0", + "lodash": "4.17.4", + "mute-stream": "0.0.7", + "run-async": "2.3.0", + "rx-lite": "4.0.8", + "rx-lite-aggregates": "4.0.8", + "string-width": "2.1.1", + "strip-ansi": "4.0.0", + "through": "2.3.8" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", + "dev": true + }, + "is-path-in-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", + "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", + "dev": true, + "requires": { + "is-path-inside": "1.0.1" + } + }, + "is-path-inside": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "dev": true, + "requires": { + "path-is-inside": "1.0.2" + } + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, + "is-resolvable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "js-yaml": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz", + "integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==", + "dev": true, + "requires": { + "argparse": "1.0.10", + "esprima": "4.0.0" + } + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "1.1.2", + "type-check": "0.3.2" + } + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + }, + "lru-cache": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", + "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", + "dev": true, + "requires": { + "pseudomap": "1.0.2", + "yallist": "2.1.2" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.0.tgz", + "integrity": "sha512-ukB2dF+u4aeJjc6IGtPNnJXfeby5d4ZqySlIBT0OEyva/DrMjVm5HkQxKnHDLKEfEQBsEnwTg9HHhtPHJdTd8w==", + "dev": true, + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.11.0", + "debug": "3.1.0", + "diff": "3.3.1", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.3", + "he": "1.1.1", + "mkdirp": "0.5.1", + "supports-color": "4.4.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "omit-empty": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/omit-empty/-/omit-empty-0.4.1.tgz", + "integrity": "sha1-KUo3gvLLIMdJfEEitiN8ncwMY6s=", + "requires": { + "has-values": "0.1.4", + "kind-of": "3.2.2", + "reduce-object": "0.1.3" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "1.2.0" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "0.1.3", + "fast-levenshtein": "2.0.6", + "levn": "0.3.0", + "prelude-ls": "1.1.2", + "type-check": "0.3.2", + "wordwrap": "1.0.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "2.0.4" + } + }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "progress": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", + "dev": true + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "readable-stream": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.4.tgz", + "integrity": "sha512-vuYxeWYM+fde14+rajzqgeohAI7YoJcHE7kXDAc4Nk0EbuKnJfqtY9YtRkLo/tqkuF7MsBQRhPnPeyjYITp3ZQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "reduce-object": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/reduce-object/-/reduce-object-0.1.3.tgz", + "integrity": "sha1-1UnUCmwpNvpOPpt4yonJMxRZQhg=", + "requires": { + "for-own": "0.1.5" + } + }, + "require-uncached": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "dev": true, + "requires": { + "caller-path": "0.1.0", + "resolve-from": "1.0.1" + } + }, + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "dev": true + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "2.0.1", + "signal-exit": "3.0.2" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "dev": true, + "requires": { + "glob": "7.1.2" + } + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "2.1.0" + } + }, + "rx-lite": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", + "dev": true + }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "dev": true, + "requires": { + "rx-lite": "4.0.8" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + } + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + }, + "table": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "dev": true, + "requires": { + "ajv": "5.5.2", + "ajv-keywords": "2.1.1", + "chalk": "2.3.1", + "lodash": "4.17.4", + "slice-ansi": "1.0.0", + "string-width": "2.1.1" + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2" + } + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "1.1.2" + } + }, + "type-detect": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.7.tgz", + "integrity": "sha512-4Rh17pAMVdMWzktddFhISRnUnFIStObtUMNGzDwlA6w/77bmGv3aBbRdCmQR6IjzfkTo9otnW+2K/cDRhKSxDA==", + "dev": true + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "which": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "dev": true, + "requires": { + "isexe": "2.0.0" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "dev": true, + "requires": { + "mkdirp": "0.5.1" + } + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..32ec3f2 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "serverless-plugin-canary-deployments", + "version": "0.1.0", + "description": "A Serverless plugin to implement canary deployment of Lambda functions", + "main": "serverless-plugin-canary-deployments.js", + "scripts": { + "test": "NODE_ENV=test ./node_modules/mocha/bin/mocha $(find ./lib/ -name '*.test.js' -not -path './node_modules/*')", + "watch": "NODE_ENV=test mocha -w $(find ./lib/ -name '*.test.js' -not -path './node_modules/*')" + }, + "author": "David García ", + "license": "ISC", + "repository": { + "url": "https://github.com/davidgf/serverless-plugin-canary-deployments.git", + "type": "git" + }, + "dependencies": { + "flat": "^4.0.0", + "lodash": "^4.17.4", + "omit-empty": "^0.4.1" + }, + "devDependencies": { + "chai": "^4.1.2", + "eslint": "^4.18.1", + "eslint-config-airbnb": "^16.1.0", + "mocha": "^5.0.0" + } +} diff --git a/sam-source-example.yaml b/sam-source-example.yaml new file mode 100644 index 0000000..213d27a --- /dev/null +++ b/sam-source-example.yaml @@ -0,0 +1,27 @@ +AWSTemplateFormatVersion: '2010-09-09' +Transform: 'AWS::Serverless-2016-10-31' +Resources: + MyFunction: + Type: 'AWS::Serverless::Function' + Properties: + Handler: handler.hello + Runtime: nodejs6.10 + CodeUri: 's3://aws-nodejs-dev-serverlessdeploymentbucket-14iyutt06erm7/serverless/aws-nodejs/dev/1515768309333-2018-01-12T14:45:09.333Z/aws-nodejs.zip' + AutoPublishAlias: live + DeploymentPreference: + Type: Linear10PercentEvery1Minute + Hooks: + PostTraffic: !Ref MyOtherFunction + # Alarms: + # - !Ref LatestVersionErrorMetricGreaterThanZeroAlarm + MyOtherFunction: + Type: 'AWS::Serverless::Function' + Properties: + Handler: handler.hello + Runtime: nodejs6.10 + CodeUri: 's3://aws-nodejs-dev-serverlessdeploymentbucket-14iyutt06erm7/serverless/aws-nodejs/dev/1515768309333-2018-01-12T14:45:09.333Z/aws-nodejs.zip' + AutoPublishAlias: public + DeploymentPreference: + Type: Canary10Percent30Minutes + # Alarms: + # - !Ref LatestVersionErrorMetricGreaterThanZeroAlarm diff --git a/serverless-plugin-canary-deployments.js b/serverless-plugin-canary-deployments.js new file mode 100644 index 0000000..32cd974 --- /dev/null +++ b/serverless-plugin-canary-deployments.js @@ -0,0 +1,175 @@ +const _ = require('lodash/fp'); +const flattenObject = require('flat'); +const CfGenerators = require('./lib/CfTemplateGenerators'); + +class ServerlessCanaryDeployments { + constructor(serverless, options) { + this.serverless = serverless; + this.options = options; + this.awsProvider = this.serverless.getProvider('aws'); + this.naming = this.awsProvider.naming; + this.service = this.serverless.service; + this.hooks = { + 'before:package:finalize': this.addCanaryDeploymentResources.bind(this) + }; + } + + get codeDeployAppName() { + const stackName = this.naming.getStackName(); + const normalizedStackName = this.naming.normalizeNameToAlphaNumericOnly(stackName); + return `${normalizedStackName}DeploymentApplication`; + } + + get compiledTpl() { + return this.service.provider.compiledCloudFormationTemplate; + } + + get withDeploymentPreferencesFns() { + return this.serverless.service.getAllFunctions() + .filter(name => _.has('deploymentSettings', this.service.getFunction(name))); + } + + addCanaryDeploymentResources() { + if (this.withDeploymentPreferencesFns.length > 0) { + const codeDeployApp = this.buildCodeDeployApp(); + const codeDeployRole = this.buildCodeDeployRole(); + const functionsResources = this.buildFunctionsResources(); + Object.assign( + this.compiledTpl.Resources, + codeDeployApp, + codeDeployRole, + ...functionsResources + ); + // console.log(JSON.stringify(this.compiledTpl)) + } + } + + buildFunctionsResources() { + return _.flatMap( + serverlessFunction => this.buildFunctionResources(serverlessFunction), + this.withDeploymentPreferencesFns + ); + } + + buildFunctionResources(serverlessFnName) { + const functionName = this.naming.getLambdaLogicalId(serverlessFnName); + const deploymentSettings = this.getDeploymentSettingsFor(serverlessFnName); + const deploymentGrTpl = this.buildFunctionDeploymentGroup({ deploymentSettings, functionName }); + const deploymentGroup = this.getResourceLogicalName(deploymentGrTpl); + const aliasTpl = this.buildFunctionAlias({ deploymentSettings, functionName, deploymentGroup }); + const functionAlias = this.getResourceLogicalName(aliasTpl); + const lambdaPermission = this.buildPermissionForAlias({ functionName, functionAlias }); + const eventsWithAlias = this.buildEventsForAlias({ functionName, functionAlias}); + return [deploymentGrTpl, aliasTpl, lambdaPermission, ...eventsWithAlias]; + } + + buildCodeDeployApp() { + const logicalName = this.codeDeployAppName; + const template = CfGenerators.codeDeploy.buildApplication(); + return { [logicalName]: template }; + } + + buildCodeDeployRole() { + const logicalName = 'CodeDeployServiceRole'; + const template = CfGenerators.iam.buildCodeDeployRole(); + return { [logicalName]: template }; + } + + buildFunctionDeploymentGroup({ deploymentSettings, functionName }) { + const logicalName = `${functionName}DeploymentGroup`; + const params = { + codeDeployAppName: this.codeDeployAppName, + deploymentSettings + }; + const template = CfGenerators.codeDeploy.buildFnDeploymentGroup(params); + return { [logicalName]: template }; + } + + buildFunctionAlias({ deploymentSettings = {}, functionName, deploymentGroup }) { + const { alias } = deploymentSettings; + const functionVersion = this.getVersionNameFor(functionName); + const logicalName = `${functionName}Alias${alias}`; + const beforeHook = this.naming.getLambdaLogicalId(deploymentSettings.preTrafficHook); + const afterHook = this.naming.getLambdaLogicalId(deploymentSettings.postTrafficHook); + const trafficShiftingSettings = { + codeDeployApp: this.codeDeployAppName, + deploymentGroup, + afterHook, + beforeHook + }; + const template = CfGenerators.lambda.buildAlias({ + alias, + functionName, + functionVersion, + trafficShiftingSettings + }); + return { [logicalName]: template }; + } + + buildPermissionForAlias({ functionName, functionAlias }) { + const permission = this.getLambdaPermissionFor(functionName); + const [logicalName, template] = Object.entries(permission)[0]; + const templateWithAlias = CfGenerators.lambda.replacePermissionFunctionWithAlias(template, functionAlias); + return { [logicalName]: templateWithAlias }; + } + + buildEventsForAlias({ functionName, functionAlias }) { + const functionEvents = this.getEventsFor(functionName); + const functionEventsEntries = Object.entries(functionEvents); + const eventsWithAlias = functionEventsEntries.map(([logicalName, event]) => { + const evt = CfGenerators.apiGateway.replaceMethodUriWithAlias(event, functionAlias); + return { [logicalName]: evt }; + }); + return eventsWithAlias; + } + + getEventsFor(functionName) { + return this.getApiGatewayMethodsFor(functionName); + } + + getApiGatewayMethodsFor(functionName) { + const isApiGMethod = _.matchesProperty('Type', 'AWS::ApiGateway::Method'); + const isMethodForFunction = _.pipe( + _.prop('Properties.Integration'), + flattenObject, + _.includes(functionName) + ); + const getMethodsForFunction = _.pipe( + _.pickBy(isApiGMethod), + _.pickBy(isMethodForFunction) + ); + return getMethodsForFunction(this.compiledTpl.Resources); + } + + getVersionNameFor(functionName) { + const isLambdaVersion = _.matchesProperty('Type', 'AWS::Lambda::Version'); + const isVersionForFunction = _.matchesProperty('Properties.FunctionName.Ref', functionName); + const getVersionNameForFunction = _.pipe( + _.pickBy(isLambdaVersion), + _.findKey(isVersionForFunction), + ); + return getVersionNameForFunction(this.compiledTpl.Resources); + } + + getLambdaPermissionFor(functionName) { + const isLambdaPermission = _.matchesProperty('Type', 'AWS::Lambda::Permission'); + const isPermissionForFunction = _.matchesProperty('Properties.FunctionName.Fn::GetAtt[0]', functionName); + const getPermissionForFunction = _.pipe( + _.pickBy(isLambdaPermission), + _.pickBy(isPermissionForFunction) + ); + return getPermissionForFunction(this.compiledTpl.Resources); + } + + getResourceLogicalName(resource) { + return _.head(_.keys(resource)); + } + + getDeploymentSettingsFor(serverlessFunction) { + const globalSettings = _.cloneDeep(this.service.custom.deploymentSettings); + const fnDeploymentSetting = this.service.getFunction(serverlessFunction).deploymentSettings; + return Object.assign({}, globalSettings, fnDeploymentSetting); + } +} + +module.exports = ServerlessCanaryDeployments;