Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Serverless-framework plugin for creating AWS Lambda Aliases

License

Notifications You must be signed in to change notification settings

digio/serverless-simple-alias

Repository files navigation

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: 'INACTIVE'
    useActiveAliasInGateway: true   # Default: false. Whether to change API Gateway to target the active alias or not
    makeLambdasActive: true  # Default: false. Whether to apply the active alias to the lambdas that are being deployed now. Could vary per environment.
    aliases: # Default: empty list. 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.

About

Serverless-framework plugin for creating AWS Lambda Aliases

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •