Simple question:
Does SAM Lambda auto-versioning using AutoPublishAlias
work for AWS::Serverless::Function
when code CodeUri
changes but the actual code that it points to doesn't?
Background
We are deploying several Lambda@Edge functions using the SAM AWS::Serverless::Function
resource type.
Our deployment runs via dropping code into an S3 bucket and then triggering a CloudFormation stack update. Our stack contains other things in addition to these Lambdas.
With this, we often have deployments that occur where the lambda code doesn't change.
Every deployment, however, the code URI changes to our newest deployment's bucket which, as intended, triggers a new version attempted to be published which is inline with note in SAM documentation (pasted below for context)
NOTE: AutoPublishAlias will publish a new version only when the CodeUri changes. Updates to other configuration (ex: MemorySize, Timeout) etc will not publish a new version. Hence your Alias will continue to point to old version that uses the old configurations.
The reason I am asking is because we've had some transient CloudFormation deployment issues that I've been trying to root cause that may be related to this. The error we get on the SAM generated version in the CloudFormation stack update is as follows:
A version for this Lambda function exists ( {some number} ). Modify the function to create a new version.
I've taken a look at the SAM code where the version is created and most of their documentation but couldn't find a clear answer.
We could likely manually create the AWS::Lambda::Function
and AWS::Lambda::Version
with a different logical ID on the version each time which should(?) fix the issue but we were trying to utilize SAM for auto-versioning of our Lambdas.
Any help is appreciated!