You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for Lambda versioning and aliases #1457
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)
Reacted by Bart Blommaerts, Gytenis Mikulenas, Franz Josef Kaiser, seanohollaren, David Duffett, Adam Mills, mtomic, hirakiuc, Frangeris Peguero, Mikhail Plavskiy and 8 more
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
@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. 👍
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."
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>
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.
@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.
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
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.
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?
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.
I think there are two main things you might want to do:
update aliases to point to the latest versions of each deployed function
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
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.
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.
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.
Activity
37 remaining items
pdkn commentedon Jul 4, 2017
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
HyperBrain commentedon Jul 4, 2017
@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)
pmuens commentedon Jul 4, 2017
@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. 👍
pdkn commentedon Jul 4, 2017
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
HyperBrain commentedon Jul 4, 2017
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>pdkn commentedon Jul 4, 2017
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.
HyperBrain commentedon Jul 4, 2017
@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.
pdkn commentedon Jul 4, 2017
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
candlerb commentedon Nov 26, 2017
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$LATESTwill always invoke the most-recently deployed version of that function.If I have
currentpoints 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 thecurrentalias to point to any previous version (I'm happy to use the aws cli to do this).I looked at
serverless-aws-aliasbut 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.coderade commentedon Dec 28, 2017
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.ymlfile:justasitsounds commentedon Feb 15, 2018
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.
candlerb commentedon Feb 15, 2018
I think there are two main things you might want to do:
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:
This would create or update an alias
prodon all functions (or selected function foo), pointing at the most recent version which was published on or before the given timestamp. If you miss--atthen it defaults to now (i.e. latest published versions), and if you miss--updatethen it could use a default name e.g.currentWorkflow then becomes:
Another useful option could be to copy aliases so that they point to the same version as an existing alias:
And for completeness:
HyperBrain commentedon Feb 15, 2018
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.
candlerb commentedon Feb 15, 2018
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.
HyperBrain commentedon Feb 15, 2018
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.