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

aws_lambda: regular deploys fail after hotswap #28237

Open
samchungy opened this issue Dec 3, 2023 · 4 comments
Open

aws_lambda: regular deploys fail after hotswap #28237

samchungy opened this issue Dec 3, 2023 · 4 comments
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. documentation This is a problem with documentation. effort/medium Medium work item – several days of effort p2

Comments

@samchungy
Copy link

samchungy commented Dec 3, 2023

Describe the bug

After deploying a lambda version with --hotswap, when you attempt to run a regular cdk deploy with the same changes it fails with the following error message:

Resource handler returned message: "Version already exists: [arn:aws:lambda:ap-southeast-2:572093383043:function:serviceName:96]. Please modify the function to create a new version. (Service: Lambda, Status Code: 409, Request ID: aa44dd2b-8347-4e8a-996e-408a52e648ec)" (RequestToken: 0af5f624-50e3-8943-96d4-16687d2fe1fb, HandlerErrorCode: AlreadyExists)

Expected Behavior

Regular cdk deploy succeeds after a hotswap deploy

Current Behavior

cdk deploy fails.

Reproduction Steps

https://github.com/samchungy/cdk-lambda-hotswap-bug

run ENVIRONMENT=dev yarn deploy

    const worker = new aws_lambda_nodejs.NodejsFunction(this, 'worker', {
      architecture: aws_lambda.Architecture.ARM_64,
      runtime: aws_lambda.Runtime.NODEJS_20_X,
      entry: './src/app.ts',
      timeout: Duration.seconds(30),
      bundling: defaultWorkerBundlingConfig,
      functionName: 'serviceName',
      environment: {
        ...defaultWorkerEnvironment,
        ...context.workerLambda.environment,
      },
    });

Run --hotswap followed by deploy without

Possible Solution

I assume this is failing because the function configuration hasn't changed between a hotswap deploy and a regular deploy. So when CF goes to sync up and the version configuration is the same it fails

My workaround at the moment is adding a dynamic description which means that the Lambda has to be deployed fresh with every deploy.

This may just have to be an accepted quirk, but perhaps some documentation around this would be great

Additional Information/Context

No response

CDK CLI Version

2.110.0

Framework Version

No response

Node.js Version

20

OS

Mac OSX

Language

TypeScript

Language Version

No response

Other information

No response

@samchungy samchungy added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 3, 2023
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Dec 3, 2023
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Dec 4, 2023
@khushail khushail self-assigned this Dec 4, 2023
@samchungy
Copy link
Author

Hey @khushail I've added a repo to reproduce

@pahud pahud added the p2 label Dec 12, 2023
@pahud
Copy link
Contributor

pahud commented Dec 12, 2023

Yes I think this is expected and should be documented.

What's happening with hotswap with lambda version is that it essentially bump the lambda version with SDK call and this causes the drift. When you cdk deploy, CFN tries to bump the original version hence conflict.

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. effort/medium Medium work item – several days of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Dec 12, 2023
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Dec 14, 2023
@samchungy
Copy link
Author

Yeah cool, it makes sense.

It's quite difficult to work with this from a CI POV. Ideally, my master build should never just suddenly break. So I think the dynamic description would be the best workaround for using hotswap.

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Dec 15, 2023
@khushail khushail removed their assignment Jul 17, 2024
@khushail khushail added the documentation This is a problem with documentation. label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. documentation This is a problem with documentation. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants