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

Allow to override the AWS::Serverless::Function generated Version SHA #1375

Closed
jmnarloch opened this issue Jan 9, 2020 · 1 comment
Closed

Comments

@jmnarloch
Copy link
Contributor

jmnarloch commented Jan 9, 2020

Description: AutoPublishAlias will lead to SAM creating a Lambda::Version with SHA computed based on Function Code configuration. This behaviour is not aligned with Lambda PublishVersion check that can lead into API call failing with error message

409 - Conflict
A version for this Lambda function exists.

This becomes problematic if you deploy the same code into S3 as new object key, SAM will attempt to create new CloudFormation Lambda version, while Lambda will reject that at runtime.

It becomes even more problematic if you use a single CloudFormation template to deploy more then one Lambda function at a time.

Steps to reproduce the issue:

  1. Create a SAM template:
Resources:
  MinimalFunction:
    Type: 'AWS::Serverless::Function'
    Properties:
      CodeUri: s3://sam-demo-bucket/hello.zip
      Handler: hello.handler
      Runtime: python2.7
      AutoPublishAlias: live
      VersionDescription: sam-testing
  1. Execute sam init && sam deploy
  2. Copy the S3 object as new key and update it in the template.
  3. Repeat this step.

Observed result:

The execution fails with stack being rollback due to A version for this Lambda function exists.

Expected result:
The end result that we would like to be able to achieve is to associated with SAM Function the SHA of the deployed code that would grant that the CloudFormation deployment will not be attempting to create new version of Lambda function each time.

i.e. this could be achieved by introducing new attribute like AutoPublishAliasCodeSha256 (or just CodeSha256 for short, though I did not want to confuse it with the existing Lambda::Version CodeSha256).

@keetonian
Copy link
Contributor

Released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants