Skip to content

Commit

Permalink
Prepare 1.2.0. Added small fix for authorizers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Schmid committed May 30, 2017
1 parent 53fa162 commit c2d4dba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ contains its entire configuration (VPC settings, environment, etc.)
## For developers
### Lifecycle events

_currently the exposed hooks are disabled after the change to the new SLS lifecycle model_
_currently the exposed hooks are not available after the change to the new SLS lifecycle model_

The plugin adds the following lifecycle events that can be hooked by other plugins:

Expand Down Expand Up @@ -341,6 +341,11 @@ and _serverless.service.provider.deployedAliasTemplates[]_.

## Version history

* 1.2.0
* Fix issue when stage is specified as Serverless variable [#45](https://github.com/HyperBrain/serverless-aws-alias/issues/45)
* Add support for SNS Lambda subscriptions [#43](https://github.com/HyperBrain/serverless-aws-alias/issues/43)
* Add support for custom authorizers [#22](https://github.com/HyperBrain/serverless-aws-alias/issues/22)

* 1.1.0
* Use stage variable in APIG [#40](https://github.com/HyperBrain/serverless-aws-alias/issues/40)
* Fix tail logging [#42](https://github.com/HyperBrain/serverless-aws-alias/issues/42)
Expand Down
21 changes: 20 additions & 1 deletion lib/stackops/apiGateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

const _ = require('lodash');
const BbPromise = require('bluebird');
const utils = require('../utils');

module.exports = function(currentTemplate, aliasStackTemplates, currentAliasStackTemplate) {
const stackName = this._provider.naming.getStackName();
Expand Down Expand Up @@ -142,7 +143,25 @@ module.exports = function(currentTemplate, aliasStackTemplates, currentAliasStac
delete userResources.Resources[name];
}

stageStack.Resources[name] = authorizer;
const aliasedName = `${name}${this._alias}`;
const authorizerRefs = utils.findReferences(stageStack.Resources, name);
_.forEach(authorizerRefs, ref => {
_.set(stageStack.Resources, ref, { Ref: aliasedName });
});

// Replace dependencies
_.forOwn(stageStack.Resources, resource => {
if (_.isString(resource.DependsOn) && resource.DependsOn === name) {
resource.DependsOn = aliasedName;
} else if (_.isArray(resource.DependsOn) && _.includes(resource.DependsOn, name)) {
_.pull(resource.DependsOn, name);
resource.DependsOn.push(aliasedName);
}
});

// Rename authorizer to be unique per alias
stageStack.Resources[aliasedName] = authorizer;
delete stageStack.Resources[name];
});

// Adjust permission to reference the function aliases
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-aws-alias",
"version": "1.1.0",
"version": "1.2.0",
"description": "Serverless plugin to support AWS function aliases",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit c2d4dba

Please sign in to comment.