Closed mriccia closed 9 hours ago
Hi, thanks for opening this issue. Unfortunately I'm not able to produce the issue following these steps:
sam init
a hello world NodeJS functionResources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
Runtime: nodejs20.x
Architectures:
- x86_64
Description: "foo1"
VersionDescription: "bar1"
AutoPublishAlias: gh7102alias
sam build
sam deploy
This deploys successfully with a Lambda version 1.
LoggingConfig
and update descriptionResources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
Runtime: nodejs20.x
Architectures:
- x86_64
Description: "foo2"
VersionDescription: "bar2"
AutoPublishAlias: gh7102alias
LoggingConfig:
ApplicationLogLevel: DEBUG
LogFormat: JSON
SystemLogLevel: DEBUG
sam build
sam deploy
I can see that the description for the original function's description is updated, along with the version's description. Additionally, a new Lambda version was published with the new logging changes to the original function.
Hello @lucashuy , thanks for the prompt response.
What's triggering the new version deployment in the steps you shared is the VersionDescription
.
Without VersionDescription
I can consistently see the Lambda Configuration being updated, without a new version being published.
Please can you test with the following steps?
sam init
a hello world NodeJS functionResources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
Runtime: nodejs20.x
Architectures:
- x86_64
Description: "foo1"
AutoPublishAlias: gh7102alias
sam build
sam deploy
This deploys successfully with a Lambda version 1.
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
Runtime: nodejs20.x
Architectures:
- x86_64
Description: "foo2"
AutoPublishAlias: gh7102alias
LoggingConfig:
ApplicationLogLevel: DEBUG
LogFormat: JSON
SystemLogLevel: DEBUG
sam build
sam deploy
I can see that the description and logging configuration for the original function are updated, but there isn't a new Lambda Version published.
@mriccia Could you try using AutoPublishAliasAllProperties
? As described in the doc:
Specifies when a new AWS::Lambda::Version is created. When true, a new Lambda version is created when any property in the Lambda function is modified. When false, a new Lambda version is created only when any of the following properties are modified:
Environment, MemorySize, or SnapStart.
Any change that results in an update to the Code property, such as CodeDict, ImageUri, or InlineCode.
I'm moving this to the SAM Repo as this question fit better under the scope of SAM than SAM CLI.
@mriccia Thanks for reaching out. As Wing has pointed out, please try out AutoPublishAliasAllProperties
property.
Closing this issue as I believe the root cause is identified and AutoPublishAliasAllProperties
is the fix for the issue. Feel free to re-open or open a new issue if this doesn't work for you or if you have additional questions.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one.
Description:
When there is a SAM template with a Lambda function property
AutoPublishAlias
, I expect that changes to the Lambda function will publish a new Lambda Version. However, it seems that a new Version is not published in certain scenarios, if there are no code changes. For example: changes to the Logging configuration, and changes to the description.Steps to reproduce:
sam build && sam deploy
a SAM project with a Lambda function with theAutoPublishAlias
setsam build && sam deploy
the project againObserved result:
The Lambda configuration has changed, however there's no new version published
Expected result:
A new Lambda Version is published and the Alias is updated
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: SAM CLI, version 1.115.0eu-west-2
Add --debug flag to command you are running