Serverless plugin for creating Lambda aliases and integrate with SAH project
npm install sah-plugin[![serverless][sls-image]][sls-url]
A Serverless plugin to create AWS Lambda aliases without imposing a way-of-working with them.
This plugin assists with two use cases:
1. Creating an "active" alias, and using that alias in API Gateway Event Sources and Event Rules.
```
npm install --save-dev sah-plugin
Add the plugin to serverless.yml:
`yaml`
plugins:
- sah-plugin
Note: Node 10.x or higher runtime required.
Inside your Serverless config, include this plugin and define a custom.sah object and specify the activeAliasName
`yaml
plugins:
- sah-plugin
...
custom:
sah:
activeAliasName: 'ACTIVE' # Default: 'ACTIVE'
useActiveAliasInEvents: 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.
sahUrl: 'http://{app_url}/api/projects/{project_id}/deployments' # Default: null. It is not mandatory but you can use it if you wish to synchronize your displays with your SAH application.
sahToken: '1|fZH1G7lyRZZKcK4AD8PaaQlXlTeeM7bc2XdjOsqBeecfb75f' # Default: null. It is not mandatory but you can use it if you wish to synchronize your displays with your SAH application.
`
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.
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.AWS::ApiGatewayV2::Integration
- Changes the existing resources (that have Property.IntegrationType of AWS_PROXY) toProperty.IntegrationUri
include the active-alias name in the AWS::Lambda::EventSourceMapping
- Changes the existing resources to include the active-alias name in the Property.FunctionNameAWS::Events::Rule
- Changes the existing resources to include the active-alias name in the Property.TargetsAWS::Lambda::Permission
- Changes the existing resources to point the Properties.FunctionName to the AWS::Lambda::Alias` resource.
[sls-image]: http://public.serverless.com/badges/v3.svg
[sls-url]: http://www.serverless.com