serverless-simple-alias

1.0.0 • Public • Published

Serverless Simple Alias Plugin

serverless npm package Build Status Coverage Status Downloads

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-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 corresponding AWS::Function::Version resource.
  • Changes the existing AWS::ApiGateway::Method resources (that have Property.Integration.Type of AWS_PROXY) to include the active-alias name in the Property.Integration.Uri
  • Changes the existing AWS::Lambda::Permission resources to point the Properties.FunctionName to the AWS::Lambda::Alias resource.

Readme

Keywords

Package Sidebar

Install

npm i serverless-simple-alias

Weekly Downloads

142

Version

1.0.0

License

Apache-2.0

Unpacked Size

32.3 kB

Total Files

7

Last publish

Collaborators

  • u_glow