Skip to content

Lambda version is not updated when a layer from the same stack has code changes #8053

Closed

Description

@pwithams

Description

When updating the code for a layer that a lambda in the same stack uses, a new layer version is updated, and the $LATEST lambda version is updated, but no new lambda numeric version is created that points to the new layer version.

It appears this is very similar to this previous issue: #4510

Every deploys "successfully" but when the versioned lambda stack output arn is referenced the version is unchanged and therefore still points to an old layer.

My guess is that looking at https://github.com/serverless/serverless/blob/master/lib/plugins/aws/package/compile/functions/index.js#L434 and the PR mentioned above the lambda version logical id is generated using the lambda source and the lambda config data. However, when using layers as described in the documentation (see example below) the layer is just a string ref to another cloudformation resource and therefore will not change unless the layer resource name is changed.

Example serverless.yml (from documentation)

https://www.serverless.com/framework/docs/providers/aws/guide/layers/

layers:
  test:
    path: layer
functions:
  hello:
    handler: handler.hello
    layers:
      - { Ref: TestLambdaLayer }

Proposed fix

If this is a bug rather than just misunderstanding of how layers within the same stack should be used, then I will submit a PR that includes the timestamped lambda layer zip S3 path so that the logical id will change each time a new layer zip is uploaded, similar to how #4510 was handled.

Activity

  1. medikoo commented on Aug 6, 2020

    @medikoo
    Contributor

    @pwithams thanks for reporting.

    There are known issues in how we calculate lambda version hash (see also: #7822)

    PR that fixes that would be very welcome!

  2. pwithams commented on Aug 11, 2020

    @pwithams
    ContributorAuthor

    I've submitted a PR for this issue. I couldn't replicate #7822 consistently so I instead added a test that I think simulates the conditions described.

  3. orr-levinger commented on Nov 5, 2023

    @orr-levinger

    This still happens.. using version 2.7.0 the plugin created version N in the lamda layers but didnt update the lambda itself toy use the version..

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions