I'm deploying an AWS lambda using CloudFormation.
In the template I use the flag AutoPublishAlias: v1
which should create a version, add the necessary permissions, and update the alias "v1" to point to the latest version.
When I deploy this change, I get the following error:
A version for this Lambda function exists ( 8 ). Modify the function to create a new version.
I am using CICD. Sometimes I redeploy the same lambda having modified another part of the CloudFormation template (e.g adding the AutoPublishAlias
flag).
I thought CloudFormation was supposed to be able to handle this correctly - only updating resources which have changed?
So why am I seeing this error, and is there a workaround other than introducing a dummy code change?
Please see https://seed.run/docs/serverless-errors/a-version-for-this-lambda-function-exists.html
The error is not Cloudformation, it's Serverless telling CF to deploy a new lambda version, which is in fact the same one.
I saw this issue after upgrading from sls 1 to 2. Had to do dummy changes for every function at once.
After that haven't seen the issue come up.