Skip to content

Commit

Permalink
Fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Boyd, Zach committed Jan 24, 2018
1 parent 266dfef commit 639c0c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions lib/stackops/snsEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ module.exports = function(currentTemplate, aliasStackTemplates, currentAliasStac
delete stageStack.Resources[name];
});

const snsSubscriptions =
_.assign({},
const snsSubscriptions =
_.assign({},
_.pickBy(stageStack.Resources, [ 'Type', 'AWS::SNS::Subscription' ]));

_.forOwn(snsSubscriptions, (subscription, name) => {
_.forOwn(snsSubscriptions, (subscription, name) => {

const functionNameRef = utils.findAllReferences(_.get(subscription.Properties, 'Endpoint'));
const functionName = _.replace(_.get(functionNameRef, '[0].ref', ''), /LambdaFunction$/, '');
const versionName = _.find(_.keys(versions), version => _.startsWith(version, functionName));
const aliasName = _.find(_.keys(aliases), alias => _.startsWith(alias, functionName));
const functionNameRef = utils.findAllReferences(_.get(subscription.Properties, 'Endpoint'));
const functionName = _.replace(_.get(functionNameRef, '[0].ref', ''), /LambdaFunction$/, '');
const versionName = _.find(_.keys(versions), version => _.startsWith(version, functionName));
const aliasName = _.find(_.keys(aliases), alias => _.startsWith(alias, functionName));

subscription.Properties.Endpoint = { Ref: aliasName };
subscription.DependsOn = [ versionName, aliasName ];
subscription.Properties.Endpoint = { Ref: aliasName };
subscription.DependsOn = [ versionName, aliasName ];

delete stageStack.Resources[name];
});
delete stageStack.Resources[name];
});

// Fetch lambda permissions. These have to be updated later to allow the aliased functions.
const snsLambdaPermissions =
Expand Down
4 changes: 2 additions & 2 deletions test/stackops/snsEvents.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ describe('SNS Events', () => {
return expect(awsAlias.aliasHandleSNSEvents({}, [], {})).to.be.fulfilled
.then(() => BbPromise.all([
expect(snsStack).to.not.have.a.nested.property('Resources.SNSTopicSlstestprojecttopic'),
expect(snsStack).to.not.have.a.nested.property('Resources.SNSTopicSubscriptionSlstestprojecttopic'),
expect(snsStack).to.not.have.a.nested.property('Resources.SNSTopicSubscriptionSlstestprojecttopic'),
expect(snsStack).to.not.have.a.nested.property('Resources.Testfct1LambdaPermissionSlstestprojecttopicSNS'),
expect(aliasStack).to.have.a.nested.property('Resources.SNSTopicSlstestprojecttopic'),
expect(aliasStack).to.have.a.nested.property('Resources.SNSTopicSubscriptionSlstestprojecttopic'),
expect(aliasStack).to.have.a.nested.property('Resources.SNSTopicSubscriptionSlstestprojecttopic'),
expect(aliasStack).to.have.a.nested.property('Resources.Testfct1LambdaPermissionSlstestprojecttopicSNS'),
]));
});
Expand Down

0 comments on commit 639c0c4

Please sign in to comment.