Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

aws-lambda: inconsistent behavior in fromLayerVersionArn during deploys #31006

Open
ykethan opened this issue Aug 1, 2024 · 2 comments
Open
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@ykethan
Copy link

ykethan commented Aug 1, 2024

Describe the bug

when modifying an existing fromLayerVersionArn value with a arn that is already attached the deploy nor synth fails

Expected Behavior

Throw an error as follows
Two different versions of the same layer are not allowed to be referenced in the same function.

Current Behavior

deploys successfully but does not change anything on the service

Reproduction Steps

  1. Create CDK app with function
  2. Attach layer using
const layer1 = lambda.LayerVersion.fromLayerVersionArn(
      this,
      "layerpy",
      "arn:aws:lambda:us-east-1:<acc>:layer:mylayer1:1"
    );

    const layer2 = lambda.LayerVersion.fromLayerVersionArn(
      this,
      "layerpy1",
      "arn:aws:lambda:us-east-1:<acc>:layer:mylayer2:1"
    );
  1. deploy
  2. modify layer2 with same layer as 1
  3. deploy and observe no errors

Possible Solution

No response

Additional Information/Context

Side note: observed after deploying two fromLayerVersionArn with same layer then if we add another fromLayerVersionArn with same layer, the cfn will fail with Two different versions of the same layer are not allowed to be referenced in the same function. which is great but the next deploy/cfn template is in a failed state rather than a rollback complete state

CDK CLI Version

2.150.0

Framework Version

No response

Node.js Version

v20.11.1

OS

MacOS

Language

TypeScript

Language Version

5.5.3

Other information

No response

@ykethan ykethan added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 1, 2024
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Aug 1, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 and removed needs-triage This issue or PR still needs to be triaged. labels Aug 2, 2024
@khushail
Copy link
Contributor

khushail commented Aug 2, 2024

@ykethan , thanks for reporting this issue.

I was able to repro this, Sharing snapshots of the repro and analysis -

  1. when both layer versions are different, the deployment succeeds which is expected -
Screenshot 2024-08-02 at 4 34 21 PM
  1. Changing the layer version to same in both layers, appears in cdk diff output as below -
Screenshot 2024-08-02 at 4 35 33 PM
  1. despite cdk diff, the deployment does not make any change and succeeds here too.
Screenshot 2024-08-02 at 4 37 54 PM

@khushail khushail added effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Aug 2, 2024
@ykethan
Copy link
Author

ykethan commented Aug 7, 2024

Hey @khushail, thanks for looking into this. just a additive to the reproduction, try adding a 3rd layer referencing the same layer which will cause a rollback failure. While this is on CFN that causes this but wanted to mention this behavior, as you will not be able to rollback from the failed state.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants