Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda Versioning Issues #823

Closed
shailendrasharma83 opened this issue Feb 25, 2019 · 8 comments
Closed

Lambda Versioning Issues #823

shailendrasharma83 opened this issue Feb 25, 2019 · 8 comments

Comments

@shailendrasharma83
Copy link

Hello Team,

This is regarding the issue which I faced during lambda versioning.

We used AutoPublishAlias in SAM template for versioning/aliasing of lambdas which has a restriction that we cannot provide custom description to versions. Intent is to pass commit id as a description as a correlation id between lambda version and commits which generated the versions.

Resource AWS::Lambda::Version is also not proving to be any help, as on the second execution I cloudformation is failing with the message that "Update to resource type AWS::Lambda::Version is not supported.". Going through several blogs I came to know that for any new version to be published we need to define an addition AWS::Lambda::Version resource. I assume we cannot perform update to Lambda Version as it is immutable resource and we have to create new version each time.

AutoPublishAlias to accept a description will help to put a relational mapping between the lambda version and the stack which created the stack. Or if you can map commit id and display it in lambda console as Tags that will also suffice the purpose.

Many Thanks.

@keetonian
Copy link
Contributor

I think we could expose an optional VersionDescription property on Serverless::Function, that would take a description that would only be added to the generated AWS::Lambda::Version resource.

This parameter would be added here to Serverless::Function:
https://github.com/awslabs/serverless-application-model/blob/master/samtranslator/model/sam_resources.py#L32

Pass parameter to version:
https://github.com/awslabs/serverless-application-model/blob/master/samtranslator/model/sam_resources.py#L98
https://github.com/awslabs/serverless-application-model/blob/master/samtranslator/model/sam_resources.py#L311

Update relevant E2E and unit tests.

@Buffer0x7cd
Copy link
Contributor

Buffer0x7cd commented Mar 3, 2019

Edit: I Think have figured out this now. I needed to set the Description attribute of the LambdaVersion Class. and the method _generate_resource_dict of Resource Class is the one doing the work of creating the Properties dictionary of a resource. After making these changes I am able to pass a VersionDescription parameter to my SAM template and it creates the lambda versions with appropriate Descriptions.

@keetonian I am currently trying to work on this issue. But I am having a bit of a hard time figuring out how does the VesrionDescription parameter will be passed to LambdaVersion class. I tried looking at the class definition of the Resource Class. From what I understood after looking at the class definition is that the attribute parameter is used to pass all the parameters that exist outside of the Properties dictionary. But I am not able to figure out how does the value of property_types dictionary is passed to a resource ( LambdaVersion In this case). Please let me know if I am missing something in my understanding of the flow.

@Buffer0x7cd
Copy link
Contributor

Hi, @keetonian My PR 835 is ready for Review. Please take a look and provide any necessary feedbacks.

@keetonian
Copy link
Contributor

Released with SAM v1.11.0!

@srogovtsev
Copy link

I've noticed that if only the VersionDescription is updated (without updating CodeUri), changeset contains only modifications to Version and Alias, and its execution fails with

Update to resource type AWS::Lambda::Version is not supported.

Am I doing something wrong?

@keetonian keetonian reopened this Sep 27, 2019
@keetonian
Copy link
Contributor

To fix this, we would need to take the VersionDescription property and add it to the hash that we put in the version resource logical id: https://github.com/awslabs/serverless-application-model/blob/develop/samtranslator/model/sam_resources.py#L387

This would force redeployments for everyone using this property, I am not sure if we want to do that at this time. A workaround for now would be to make a change to your CodeUri property, which will force a redeployment of this version resource. If you are using the SAM or AWS CLI to package your lambda function, all this takes is any simple change to your code and this property will change.

@dalumiller
Copy link
Contributor

@keetonian As far as I've tested, just changing the FunctionName of an AWS::Serverless::Function property does force an update of any lambda. That's how I currently get around my issue #1267. Is there a reason that this FunctionName updating mechanism would not be preferred over using the AWS::Lambda::Version?

@hoffa
Copy link
Contributor

hoffa commented Dec 19, 2022

The original issue was addressed in #835, and the follow-up question about updating version when VersionDescription changes is covered by #413; closing.

@hoffa hoffa closed this as completed Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants