serverless-simple-alias v1.0.0
Serverless Simple Alias Plugin
A Serverless plugin to create AWS Lambda aliases without imposing a way-of-working with them.
Motivation
The existing Serverless alias-plugin presumes/enforces a way of working that may be more complex than you require.
This plugin assists with two use cases: 1. Creating an "active" alias, and using that alias in API Gateway. 2. Allowing any other alias to be applied to the functions in the Serverless config.
Installation
npm install --save-dev serverless-simple-aliasAdd the plugin to serverless.yml:
plugins:
- serverless-simple-aliasNote: Node 10.x or higher runtime required.
Usage
Inside your Serverless config, include this plugin and define a custom.simpleAlias object and specify the activeAliasName
This configuration is optional. If no configuration is specified, default values will be used.
plugins:
- serverless-simple-alias
...
custom:
simpleAlias:
activeAliasName: 'ACTIVE' # Default: 'ACTIVE'
useActiveAliasInGateway: true # Default: true. Whether to change API Gateway to target the active alias or not
makeLambdasActive: true # Default: true. Whether to apply the active alias to the lambdas that are being deployed now. Could vary per environment.
aliases: # An array of additional aliases to apply when deploying the Lambda functions
- '${self:provider.environment.packageVersion}`
In practice, different environments have different deployment requirements. For example, in production it may be preferable to not deploy the new versions of the Lambdas with the active tag.
How it works
This plugin changes the following generated AWS CloudFormation templates:
- Adds an
AWS::Lambda::Aliasresource for each alias, per function, and links each resource to the correspondingAWS::Function::Versionresource. - Changes the existing
AWS::ApiGateway::Methodresources (that haveProperty.Integration.TypeofAWS_PROXY) to include the active-alias name in theProperty.Integration.Uri - Changes the existing
AWS::Lambda::Permissionresources to point theProperties.FunctionNameto theAWS::Lambda::Aliasresource.
5 years ago