Skip to content

Commit

Permalink
Merge pull request #41 from HyperBrain/use-alias-stage-variable
Browse files Browse the repository at this point in the history
Use stage variable to set alias in APIG
  • Loading branch information
HyperBrain authored May 25, 2017
2 parents 67417d4 + 5a48d6b commit 0403a14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ as name.
The created API Gateway stage has the stage variables SERVERLESS_STAGE and
SERVERLESS_ALIAS set to the corresponding values.

Upcoming: There will be a configuration possibility to configure the APIG
stage parameters separately soon.
If you want to test your APIG endpoints in the AWS ApiGateway console, you have
to set the SERVERLESS_ALIAS stage variable to the alias that will be used for the
Lambda invocation. This will call the aliased function version.

Deployed stages have the alias stage variable set fixed, so a deployed alias stage is
hard-wired to the aliased Lambda versions.

## Reference the current alias in your service

Expand Down
3 changes: 2 additions & 1 deletion lib/stackops/apiGateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ module.exports = function(currentTemplate, aliasStackTemplates, currentAliasStac
const uriParts = method.Properties.Integration.Uri['Fn::Join'][1];
const funcIndex = _.findIndex(uriParts, part => _.has(part, 'Fn::GetAtt'));

uriParts.splice(funcIndex + 1, 0, `:${this._alias}`);
// Use the SERVERLESS_ALIAS stage variable to determine the called function alias
uriParts.splice(funcIndex + 1, 0, ':${stageVariables.SERVERLESS_ALIAS}');
}

// Check for user resource overrides
Expand Down

0 comments on commit 0403a14

Please sign in to comment.