serverless-simple-alias
v1.0.0
Published
Serverless plugin for creating Lambda aliases without imposing a workflow (YMMV)
Downloads
526
Readme
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:
- Creating an "active" alias, and using that alias in API Gateway.
- Allowing any other alias to be applied to the functions in the Serverless config.
Installation
npm install --save-dev serverless-simple-alias
Add the plugin to serverless.yml:
plugins:
- serverless-simple-alias
Note: 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::Alias
resource for each alias, per function, and links each resource to the correspondingAWS::Function::Version
resource. - Changes the existing
AWS::ApiGateway::Method
resources (that haveProperty.Integration.Type
ofAWS_PROXY
) to include the active-alias name in theProperty.Integration.Uri
- Changes the existing
AWS::Lambda::Permission
resources to point theProperties.FunctionName
to theAWS::Lambda::Alias
resource.