serverless-plugin-canary-deployments
Advanced tools
Comparing version 0.4.5 to 0.4.6
@@ -0,1 +1,4 @@ | ||
# 0.4.6 (14.02.2019) | ||
- Add support for CloudWatchEvents | ||
# 0.4.5 (14.01.2019) | ||
@@ -2,0 +5,0 @@ - Allow configuring CodeDeploy triggers |
@@ -7,2 +7,3 @@ const CodeDeploy = require('./CodeDeploy'); | ||
const S3 = require('./S3'); | ||
const CloudWatchEvents = require('./CloudWatchEvents'); | ||
@@ -15,1 +16,2 @@ module.exports.codeDeploy = CodeDeploy; | ||
module.exports.s3 = S3; | ||
module.exports.cloudWatchEvents = CloudWatchEvents; |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"description": "A Serverless plugin to implement canary deployment of Lambda functions", | ||
@@ -16,3 +16,4 @@ "main": "serverless-plugin-canary-deployments.js", | ||
"contributors": [ | ||
"Carlos Castellanos <ccverak@gmail.com> (https://github.com/ccverak/)" | ||
"Carlos Castellanos <ccverak@gmail.com> (https://github.com/ccverak/)", | ||
"Kartikeya Verma <kverma23@outlook.com> (https://github.com/kverma23/)" | ||
], | ||
@@ -19,0 +20,0 @@ "license": "ISC", |
@@ -100,3 +100,3 @@ [![npm version](https://badge.fury.io/js/serverless-plugin-canary-deployments.svg)](https://badge.fury.io/js/serverless-plugin-canary-deployments) | ||
For now, the plugin only works with Lambda functions invoked by API Gateway, Stream based (such as the triggered by Kinesis or DynamoDB Streams), SNS based events and S3 events. More events will be added soon. | ||
For now, the plugin only works with Lambda functions invoked by API Gateway, Stream based (such as the triggered by Kinesis or DynamoDB Streams), SNS based events, S3 events and CloudWatch events. More events will be added soon. | ||
@@ -103,0 +103,0 @@ ## License |
@@ -146,3 +146,4 @@ const _ = require('lodash/fp'); | ||
'AWS::SNS::Topic': CfGenerators.sns.replaceTopicSubscriptionFunctionWithAlias, | ||
'AWS::S3::Bucket': CfGenerators.s3.replaceS3BucketFunctionWithAlias | ||
'AWS::S3::Bucket': CfGenerators.s3.replaceS3BucketFunctionWithAlias, | ||
'AWS::Events::Rule': CfGenerators.cloudWatchEvents.replaceCloudWatchEventRuleTargetWithAlias | ||
}; | ||
@@ -163,3 +164,4 @@ const functionEvents = this.getEventsFor(functionName); | ||
const s3Events = this.getS3EventsFor(functionName); | ||
return Object.assign({}, apiGatewayMethods, eventSourceMappings, snsTopics, s3Events); | ||
const cloudWatchEvents = this.getCloudWatchEventsFor(functionName); | ||
return Object.assign({}, apiGatewayMethods, eventSourceMappings, snsTopics, s3Events, cloudWatchEvents); | ||
} | ||
@@ -210,2 +212,17 @@ | ||
getCloudWatchEventsFor(functionName) { | ||
const isEventSourceMapping = _.matchesProperty('Type', 'AWS::Events::Rule'); | ||
const isMappingForFunction = _.pipe( | ||
_.prop('Properties.Targets'), | ||
_.map(_.prop('Arn.Fn::GetAtt')), | ||
_.flatten, | ||
_.includes(functionName) | ||
); | ||
const getMappingsForFunction = _.pipe( | ||
_.pickBy(isEventSourceMapping), | ||
_.pickBy(isMappingForFunction) | ||
); | ||
return getMappingsForFunction(this.compiledTpl.Resources); | ||
} | ||
getS3EventsFor(functionName) { | ||
@@ -212,0 +229,0 @@ const isEventSourceMapping = _.matchesProperty('Type', 'AWS::S3::Bucket'); |
223173
43
7573