MapLion
MapLion

Reputation: 1131

Lambda Function Aliases with the Serverless Framework?

Is possible to use a Lambda function alias (https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html) with the Serverless Framework? If so, does anyone have an example of how that is done?

Update:

I have found it within SAM:

AutoPublishAlias: By adding this property and specifying an alias name, AWS SAM:

Detects when new code is being deployed, based on changes to the Lambda function's Amazon S3 URI.

Creates and publishes an updated version of that function with the latest code.

Creates an alias with a name that you provide (unless an alias already exists), and points to the updated version of the Lambda function. Function invocations should use the alias qualifier to take advantage of this. If you aren't familiar with Lambda function versioning and aliases, see AWS Lambda Function Versioning and Aliases .

https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/automating-updates-to-serverless-apps.html

Is there a way to do this in the Serverless Framework?

Upvotes: 7

Views: 4868

Answers (1)

MapLion
MapLion

Reputation: 1131

I was able to accomplish this utilizing a plugin called serverless-plugin-canary-deployments: https://github.com/davidgf/serverless-plugin-canary-deployments

I found it from this blog post: https://www.serverless.com/blog/manage-canary-deployments-lambda-functions-serverless-framework

Example:

service: sls-canary-example

provider:
  name: aws
  runtime: nodejs6.10

plugins:
  - serverless-plugin-canary-deployments

functions:
  hello:
    handler: handler.hello
    events:
      - http: get hello
    deploymentSettings:
      type: Linear10PercentEvery1Minute
      alias: Live

Serverless.com confirmed with me that there is no native way to do this, but I think this plugin does what I need it to do, with the caveat that deploymentSettings does not pass the configuration validation, so you will get a warning on deploy.

Upvotes: 5

Related Questions