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

Feature Request : When 'AWS::Serverless::LayerVersion' is updated then to publish a new version of the Lambda function #1777

Closed
hnbalach opened this issue Nov 7, 2020 · 1 comment

Comments

@hnbalach
Copy link

hnbalach commented Nov 7, 2020

Description:

Presently when the 'AutoPublishAlias' is set in the template for the Serverless Function, then during each update on the Function code publishes new Lambda Function Version. However, if we make only changes to the Lambda layer code and then deploy the changes through SAM-CLI. The new Lambda Function Version is not published and thus the Lambda function would still be using the older version of the Lambda Layer.

So it would be great if a new property similar to 'AutoPublishAlias' is created for the scenario where the Update only on the Lambda layer should publish a new version of the lambda Function.

Steps to reproduce the issue:

  1. Create a SAM application with a Layer and then build & deploy it using SAM-CLI. (commands 'sam-build' & 'sam deploy')

SAM template ->

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  sam-app
  Sample SAM Template for sam-app

Globals:
  Function:
    Timeout: 3
    Layers:
      - Ref: MyLayer1

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function 
    Properties:
      CodeUri: hello_world/
      Handler: app.lambda_handler
      Runtime: python3.8
      AutoPublishAlias: live
      DeploymentPreference:
        Type: AllAtOnce
      Events:
        HelloWorld:
          Type: Api
          Properties:
            Path: /hello
            Method: get

  MyLayer1:
    Type: AWS::Serverless::LayerVersion
    Properties:
      Description: testing layer
      ContentUri: ./layertest
      CompatibleRuntimes:
        - python3.8
      LayerName:
       Fn::Sub: ${AWS::StackName}-common
      RetentionPolicy: Delete
  1. Next update the Lambda Layer code only and again run the commands 'sam-build' & 'sam deploy'.

Observed result:

The Lambda Layer is updated to a newer version and also the Lambda function with $LATEST version gets the Layer version updated. However the changes in Layer does not get reflected as the new version of Lambda function is not published.

Expected result:

The Lambda Layer is updated to a newer version and the new version of the Lambda Function is published .

@hawflau hawflau added stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/feature area/resource/function area/resource/layer-version and removed stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/feature labels Nov 9, 2020
@hawflau
Copy link
Contributor

hawflau commented Nov 10, 2020

Hi @hnbalach Thanks for your feature request!
After trying with your template, I think the problem you observed is actually a bug that's reported in #1640.
Closing in favor of #1640

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

No branches or pull requests

2 participants