serverless-plugin-canary-deployments
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -0,1 +1,4 @@ | ||
# 0.4.2 (18.04.2018) | ||
- Add configuration for enabling canary deployments on a per stage basis | ||
# 0.4.1 (16.04.2018) | ||
@@ -2,0 +5,0 @@ - Add configurable Role for CodeDeploy |
{ | ||
"service": "canary-deployments-test", | ||
"custom": { | ||
"deploymentSettings": { | ||
"stages": [ | ||
"dev" | ||
] | ||
} | ||
}, | ||
"functions": { | ||
@@ -4,0 +11,0 @@ "hello": { |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "A Serverless plugin to implement canary deployment of Lambda functions", | ||
@@ -9,0 +9,0 @@ "main": "serverless-plugin-canary-deployments.js", |
@@ -75,2 +75,5 @@ [![npm version](https://badge.fury.io/js/serverless-plugin-canary-deployments.svg)](https://badge.fury.io/js/serverless-plugin-canary-deployments) | ||
codeDeployRole: some_arn_value | ||
stages: | ||
- dev | ||
- prod | ||
@@ -83,3 +86,4 @@ functions: | ||
* `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. | ||
* `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. | ||
* `stages`: (optional) list of stages where you want to deploy your functions gradually. If not present, it assumes that are all of them. | ||
@@ -86,0 +90,0 @@ ## How it works |
@@ -36,4 +36,8 @@ const _ = require('lodash/fp'); | ||
get currentStage() { | ||
return this.awsProvider.getStage(); | ||
} | ||
addCanaryDeploymentResources() { | ||
if (this.withDeploymentPreferencesFns.length > 0) { | ||
if (this.shouldDeployDeployGradually()) { | ||
const codeDeployApp = this.buildCodeDeployApp(); | ||
@@ -51,2 +55,11 @@ const codeDeployRole = this.buildCodeDeployRole(); | ||
shouldDeployDeployGradually() { | ||
return this.withDeploymentPreferencesFns.length > 0 && this.currentStageEnabled(); | ||
} | ||
currentStageEnabled() { | ||
const enabledStages = _.getOr([], 'stages', this.globalSettings); | ||
return _.isEmpty(enabledStages) || _.includes(this.currentStage, enabledStages); | ||
} | ||
buildFunctionsResources() { | ||
@@ -53,0 +66,0 @@ return _.flatMap( |
160002
35
5335
103