Unable to deploy new Lambda versions with AutoPublishAlias
See original GitHub issueI have a serverless template that has AutoPublishAlias
set to the environment name I’m deploying into.
I need to have AutoPublishAlias
set in order to use ProvisionedConcurrencyConfig
. However, I can’t control the version number of the published Lambda from the serverless resource type. The docs say:
This AWS SAM property generates two additional resources: an AWS::Lambda::Version resource and an AWS::Lambda::Alias resource.
Since this generates the two additional resources, I’m not able to specify the version number of the Lambda. After I’ve run dotnet lambda deploy-serverless
I am unable to run it a second time as a Lambda already exists with the same version number. I don’t really want the Alias to change, just the version of the Alias.
Note: I’m not using Alias to differentiate environments. Dedicated Lambda’s are deployed per environment as the resource name includes the environment name. As environment parameter changes, the resource names will as well.
For a working example, you can clone my feature branch and perform the following steps:
- Create S3 bucket called focusmark-dev-deployments
- Run
dotnet lambda publish-layer FocusMarkApiProjectsLayer --layer-type runtime-package-store --s3-bucket focusmark-dev-deployments
from the FocusMark/src/FocusMark.Api.Projects directory - Update the aws-lambda-tools-defaults.json file by changing the
LambdaApiLayers
template-parameter with the ARN of the deployed layer above. - Run
dotnet lambda deploy-serverless
from the FocusMark/src/FocusMark.Api.Projects directory
When completed, change the provisioned concurrency configuration from 2 to 3 and re-run dotnet lambda deploy-serverless
. The error will report:
A version for this Lambda function exists ( 1 ). Modify the function to create a new version.
My understanding of how the version number is created is that it generates a hash of the CodeUri & function logical-id. I’m not pre-deploying the Lambda into S3, it’s being deployed by the CLI extension. When I download the template pushed to S3 by the CLI, I see the CodeUri
is set to s3://<obfuscated-bucket>/<obfuscated-path>/CreateProjectCommand-CodeUri-637114132146239023-637114132179701965.zip
and it changes with each deployment. This should be sufficient for creating a unique hash with each deployment.
What I think is happening is that my source code isn’t changing, just the template in this case as I want to increase the provisioned concurrency. CloudFormation then fails because the version number hash is the same as the code wasn’t re-deployed. I don’t want to make small changes to the code all the time just to force a new source deployment if that is the case. Are there any recommended work-arounds?
Thanks for any guidance on this!
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Hey @jmnarloch , Could you provide more detail on how to use AutoPublishCodeSha256? I could not find much documentation and I having several errors with my template.
Im using all these properties: Properties: AutoPublishAlias: live AutoPublishCodeSha256: 1db85af3d9db8c7e63dfd243ef6751e665ffabc0452c172be5ab73b5004c2ce4
We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.