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

Bug: No new Lambda Versions are deployed with Lambda configurations changes #3622

Closed
mriccia opened this issue May 24, 2024 · 6 comments
Closed
Labels
blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days

Comments

@mriccia
Copy link

mriccia commented May 24, 2024

Description:

When there is a SAM template with a Lambda function property AutoPublishAlias, I expect that changes to the Lambda function will publish a new Lambda Version.
However, it seems that a new Version is not published in certain scenarios, if there are no code changes. For example: changes to the Logging configuration, and changes to the description.

Steps to reproduce:

  1. sam build && sam deploy a SAM project with a Lambda function with the AutoPublishAlias set
  2. Make changes to the Logging configuration
  3. sam build && sam deploy the project again

Observed result:

The Lambda configuration has changed, however there's no new version published

Expected result:

A new Lambda Version is published and the Alias is updated

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac OS
  2. sam --version: SAM CLI, version 1.115.0
  3. AWS region: eu-west-2
sam --info --debug
{ 
  "version": "1.115.0",
  "system": {
    "python": "3.12.3",
    "os": "macOS-14.4.1-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "25.0.3",
    "aws_cdk": "2.139.0 (build 2699ffd)",
    "terraform": "1.4.2"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Add --debug flag to command you are running

@mriccia mriccia added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label May 24, 2024
@lucashuy
Copy link
Contributor

Hi, thanks for opening this issue. Unfortunately I'm not able to produce the issue following these steps:

1. Initial state

  1. sam init a hello world NodeJS function
  2. modify the function to look something like this:
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: hello-world/
      Handler: app.lambdaHandler
      Runtime: nodejs20.x
      Architectures:
        - x86_64
      Description: "foo1"
      VersionDescription: "bar1"
      AutoPublishAlias: gh7102alias
  1. sam build
  2. sam deploy

This deploys successfully with a Lambda version 1.

2. Adding LoggingConfig and update description

  1. modify the function
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: hello-world/
      Handler: app.lambdaHandler
      Runtime: nodejs20.x
      Architectures:
        - x86_64
      Description: "foo2"
      VersionDescription: "bar2"
      AutoPublishAlias: gh7102alias
      LoggingConfig:
          ApplicationLogLevel: DEBUG
          LogFormat: JSON
          SystemLogLevel: DEBUG
  1. sam build
  2. sam deploy

I can see that the description for the original function's description is updated, along with the version's description. Additionally, a new Lambda version was published with the new logging changes to the original function.

@lucashuy lucashuy added blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels May 24, 2024
@mriccia
Copy link
Author

mriccia commented May 27, 2024

Hello @lucashuy , thanks for the prompt response.
What's triggering the new version deployment in the steps you shared is the VersionDescription.
Without VersionDescription I can consistently see the Lambda Configuration being updated, without a new version being published.
Please can you test with the following steps?

Initial state

  1. sam init a hello world NodeJS function
  2. modify the function to look something like this:
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: hello-world/
      Handler: app.lambdaHandler
      Runtime: nodejs20.x
      Architectures:
        - x86_64
      Description: "foo1"
      AutoPublishAlias: gh7102alias
  1. sam build
  2. sam deploy

This deploys successfully with a Lambda version 1.

Adding LoggingConfig and update description

  1. modify the function
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: hello-world/
      Handler: app.lambdaHandler
      Runtime: nodejs20.x
      Architectures:
        - x86_64
      Description: "foo2"
      AutoPublishAlias: gh7102alias
      LoggingConfig:
          ApplicationLogLevel: DEBUG
          LogFormat: JSON
          SystemLogLevel: DEBUG
  1. sam build
  2. sam deploy

I can see that the description and logging configuration for the original function are updated, but there isn't a new Lambda Version published.

@hawflau
Copy link
Contributor

hawflau commented Jun 27, 2024

@mriccia Could you try using AutoPublishAliasAllProperties? As described in the doc:

Specifies when a new AWS::Lambda::Version is created. When true, a new Lambda version is created when any property in the Lambda function is modified. When false, a new Lambda version is created only when any of the following properties are modified:

  • Environment, MemorySize, or SnapStart.

  • Any change that results in an update to the Code property, such as CodeDict, ImageUri, or InlineCode.

I'm moving this to the SAM Repo as this question fit better under the scope of SAM than SAM CLI.

@hawflau hawflau transferred this issue from aws/aws-sam-cli Jun 27, 2024
@GavinZZ
Copy link
Contributor

GavinZZ commented Jun 27, 2024

@mriccia Thanks for reaching out. As Wing has pointed out, please try out AutoPublishAliasAllProperties property.

@GavinZZ
Copy link
Contributor

GavinZZ commented Jul 4, 2024

Closing this issue as I believe the root cause is identified and AutoPublishAliasAllProperties is the fix for the issue. Feel free to re-open or open a new issue if this doesn't work for you or if you have additional questions.

@GavinZZ GavinZZ closed this as completed Jul 4, 2024
Copy link
Contributor

github-actions bot commented Jul 4, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days
Projects
None yet
Development

No branches or pull requests

4 participants