Skip to content

Add support for Lambda versioning and aliases #1457

Closed

Description

@pmuens

The lambda function get's replaced every time a new version is deployed.

We should keep track of the lambda versions and enable lambda versioning / alias support.

Things to investigate: "What about the bucket cleanup and Lambda versioning?" (#1504 / #1477)

Activity

  1. modified the milestones: , on Jun 30, 2016
  2. self-assigned this
    on Jul 12, 2016
  3. modified the milestones: , on Jul 25, 2016
  4. added this to the v1.0.0-beta.2 milestone on Aug 1, 2016
  5. 37 remaining items

  6. pdkn commented on Jul 4, 2017

    @pdkn

    Hi Guys, We're using serverless to deploy Lambda for Alexa skills. Amazon have recommended we start using aliasing to manage production versioning which give us ability to lock down the ARN while also allowing us to make quick hotfixes should we need to. We can only do this using serverless once there's support for updating alias version pointers. Can we kindly request this feature? Thanks

  7. HyperBrain commented on Jul 4, 2017

    @HyperBrain
    Contributor

    @pdkn You can try the alias plugin: https://github.com/HyperBrain/serverless-aws-alias (also on npmjs).

    Please give me feedback if anything with the plugin does not meet your requirements (or directly create an issue there)

  8. pmuens commented on Jul 4, 2017

    @pmuens
    ContributorAuthor

    @pdkn You can try the alias plugin: https://github.com/HyperBrain/serverless-aws-alias (also on npmjs).

    Please give me feedback if anything with the plugin does not meet your requirements (or directly create an issue there)

    @pdkn Thanks for your question 👍 !

    @HyperBrain plugin is really feature rich and should do the trick in that case. So definitely give it a spin as it's the go-to solution for such a problem right now. 👍

  9. pdkn commented on Jul 4, 2017

    @pdkn

    Many Thanks @pmuens @HyperBrain , I've tried using this plugin but can't see how to update the version an Alias points to? The Docs state: "The aliased version is read only in the AWS console, so it is guaranteed that the environment and function parameters (memory, etc.) cannot be changed for a deployed version by accident, as it can be done with the $LATEST qualifier. This adds an additional level of stability to your deployment process."

    Am I missing a trick? We're after this functionality - http://docs.aws.amazon.com/lambda/latest/dg/API_UpdateAlias.html

  10. HyperBrain commented on Jul 4, 2017

    @HyperBrain
    Contributor

    Ok. That is a missing feature (to promote an already deployed version of a Serverless service) to a different already deployed version (alias). Technically this would be shifting the aliases.

    Currently the behavior is, that you can deploy the service to different aliases, whereas each deployment will create a new function version and sets the selected alias to is. So you can deploy blue and green as different aliases, but you have to redeploy the "blue" version to the "green" alias to have it as "green" available. Then you would deploy a new test version to the "blue" alias and test it.

    In general there should be no quality implications if you do it that way until an alias shift/promotion is available, if you use "serverless package" and "serverless deploy" separately, where you have a clear distinction between build and deploy. You can store the built artifacts after package and deploy them to different aliases with "serverless deploy". The only difference is, that the same ZIP is redeployed to a different version, but the alias is set there.

    In general you can call your lambdas with the "Qualifier" set to the alias and the arns are just extended with :<aliasname>

  11. pdkn commented on Jul 4, 2017

    @pdkn

    Many Thanks @HyperBrain. My understanding was once an Alexa skill is released the Alias (arn) can't be redeployed (where as it's version pointer can be updated)? I'll do some more digging. In the meantime is there any aversion your end to look at adding a feature like this to the roadmap? Thanks again.

  12. HyperBrain commented on Jul 4, 2017

    @HyperBrain
    Contributor

    @pdkn Not at all 😃 . Also for us (and I think many more people) it would be a good addition to have a promotion feature. Please feel free to add a feature request.

    Regarding the redeployment of the alias arn - that might be meant for the skill's side, which would be independent of the lambda side. You could do a test to have a skill referencing an alias (deployed with sls deploy --alias=XXXX) test it, maybe change some code and then redeploy with the same command line.
    Would be interesting to know if the skill then works on the changed code.

  13. pdkn commented on Jul 4, 2017

    @pdkn

    Ace, will do. Our current released Alexa Skill isn't using Aliasing so I'll need to wait till we resubmit a new version with Aliasing in place to verify. In the meantime I'll reach out to Amazon for any insights. Thanks Again

  14. candlerb commented on Nov 26, 2017

    @candlerb

    Ok. That is a missing feature (to promote an already deployed version of a Serverless service) to a different already deployed version (alias). Technically this would be shifting the aliases.

    For me, what I want is that on every deploy, update an alias (e.g. "current") to point to the version just published. That's it.

    Aside: this is not the same as pointing the alias to $LATEST. That is permitted, but an alias which points to $LATEST will always invoke the most-recently deployed version of that function.

    If I have current points to the version just published, and have the clients invoke <function>:current, then normally clients will run the latest version; BUT it also allows me to swing the current alias to point to any previous version (I'm happy to use the aws cli to do this).

    I looked at serverless-aws-alias but it seems to do a bunch of other stuff, like adding an alias equal to the name of the stage, which I don't want; after all, each stage is already in its own entirely separate CloudFormation stack, and the stage is already embedded in the function name. I just want a single well-known alias for the version to be run.

  15. coderade commented on Dec 28, 2017

    @coderade

    Hi guys, I'm trying to create a trigger automatically for each version of my functions published.

    When I deploy my serverless app,the trigger is created, but for my published version of the lambda function the trigger doesn't exists, only the resources.

    There is any way to create the trigger for my versioned lambdas too?

    my serverless.yml file:

    service: serverless-lambdas
    provider:
      name: aws
      runtime: nodejs6.10
      iamRoleStatements:
        - Effect: "Allow"
          Action:
            - "ses:*"
            - "iot:*"
          Resource:
            - "*"
    
    functions:
       function1:
        name: "function1"
        handler: function1/handler.function1
        events:
          - iot:
              name: "iotEvent1"
              sql: "SELECT EXAMPLE"
              sqlVersion: "2016-03-23"
              enabled: true
  16. justasitsounds commented on Feb 15, 2018

    @justasitsounds

    I'm also stuck trying to create triggers for versioned lambda functions - in my case it's for an Alexa skill and as @pdkn said above, once a skill has been certified you can't change the skill configuration with a new ARN.

  17. candlerb commented on Feb 15, 2018

    @candlerb

    I think there are two main things you might want to do:

    1. update aliases to point to the latest versions of each deployed function
    2. update aliases to point to some previous version (rollback)

    There should be a simple and general way to do this, bearing in mind that a single serverless.yml may have multiple lambdas, and they may have a different set of published version numbers (this happens if you start developing and publishing one lambda, and then add another lambda)

    I came up with this idea:

    sls alias --update prod --at 20180214T1230 [-f foo]
    

    This would create or update an alias prod on all functions (or selected function foo), pointing at the most recent version which was published on or before the given timestamp. If you miss --at then it defaults to now (i.e. latest published versions), and if you miss --update then it could use a default name e.g. current

    Workflow then becomes:

    sls deploy
    sls alias
    # perform testing on foo:current and bar:current
    # (or skip this and test foo:$LATEST and bar:$LATEST)
    
    sls alias --update uat
    # perform testing on foo:uat and bar:uat
    
    sls alias --update prod
    # now production clients are using latest code
    
    # panic! rollback required
    sls alias --update prod --at 20180214T1230
    

    Another useful option could be to copy aliases so that they point to the same version as an existing alias:

    sls alias --update prod_safe --copy prod
    sls alias --update prod
    ... prod is now on latest code
    
    ... rollback to known good version
    sls alias --update prod --copy prod_safe
    

    And for completeness:

    # for each function show all aliases and which version number/timestamp they point to
    sls alias --list
    
    sls alias --delete prod_safe
    
  18. HyperBrain commented on Feb 15, 2018

    @HyperBrain
    Contributor

    There should be a simple and general way to do this, bearing in mind [...]

    This only is simple as long as you do not use any Lambda function event declarations in your yaml service definition. As soon as you have additional triggers like APIG endpoints, SNS or anything else, these will not call your aliased functions but still refer to and call the $LATEST version. It even becomes more tricky as soon as you start using authorizers. I.e. when you'll use a real-world project.

    It was when I realized the complexity of a suitable approach that I started with the aws-alias plugin and tried to solve these dependencies properly.

  19. candlerb commented on Feb 15, 2018

    @candlerb

    I had a look at aws-alias, but it seems to combine deploy with changing of alias - that is, I couldn't see a way to move the alias to point back to a previous version, independently of deploying new code. But I could have misunderstood.

  20. HyperBrain commented on Feb 15, 2018

    @HyperBrain
    Contributor

    Yes, that's right. It is intended to use aliases for different parallel deployments (like CI/CD environments or stages) and not specific historic versions.
    However, there is a feature request open that would allow "promotion", so an alias can be copied (promoted) to a different alias, i.e. published without rebuilding/redeploying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions