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-nodejs] LambdaNodeJs bundles lambda code into cdk.staging directory when using cdk synth --no-staging #9189

Open
dave-graham opened this issue Jul 21, 2020 · 12 comments
Labels
@aws-cdk/aws-lambda-nodejs bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@dave-graham
Copy link

When cdk synth --no-staging is run, it should still refer to the lambda file that has been developed, to enable local development and debugging.

I would expect the aws:asset:path to still refer to the original file, rather than bundled version when adding --no-staging, but it's looking like:

aws:asset:path: /Users/user-name/path-to-project/.cdk.staging/asset-bundle-L5zSs8

This is preventing me from using breakpoints in vscode to debug, using for example:

echo '{}' | sam local invoke -d 9999 ServerlessFunctionName

Or even just general debugging, as I need to run a cdk synth each time I make a change to the lambda.

Also thanks for the work on lambda-nodejs, it's great, and really simplifies some workflows I would otherwise have to manually put together.

This is 🐛 Bug Report

@dave-graham dave-graham added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 21, 2020
@dave-graham dave-graham changed the title [aws-lambda-nodejs] LambdaNodeJs bundles lambda code into output directory when using cdk synth --no-staging [aws-lambda-nodejs] LambdaNodeJs bundles lambda code into cdk.staging directory when using cdk synth --no-staging Jul 21, 2020
@jogold
Copy link
Contributor

jogold commented Jul 23, 2020

@eladb what do you think here? Should we simply disable bundling when staging is disabled?

if (props.bundling && !stagingDisabled) {

if (props.bundling) {
this.bundleDir = this.bundle(props.bundling);
}

@eladb
Copy link
Contributor

eladb commented Jul 26, 2020

Feels weird to completely disable asset bundling for all assets (whether they are part of your app or not). Would it make sense to specify which assets we want to skip? This whole behavior around disabling asset staging feels a bit hacky, but the use case of local lambda debugging still stands.

Also, I would include a warning if bundling is disabled.

@eladb eladb added effort/small Small work item – less than a day of effort p1 labels Jul 26, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Jul 27, 2020
@eladb eladb removed their assignment Feb 25, 2021
@danielleletartesonos
Copy link

Curious what the status is on this bug? I'm experiencing the same issue.

@github-actions
Copy link

This issue has not received any attention in 1 year. 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 May 10, 2022
@Sevi7
Copy link

Sevi7 commented May 10, 2022

I write this comment so the issue is not closed and can be solved

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 11, 2022
@corymhall
Copy link
Contributor

@Sevi7 @dave-graham Is this still an issue for you? I'm not sure I follow how you would be able to have the Lambda code updated without re-running synth since synth is what bundles the code?

@corymhall corymhall added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 9, 2022
@github-actions
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 closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Aug 11, 2022
@Sevi7
Copy link

Sevi7 commented Aug 17, 2022

@corymhall I think we did not mention to have the Lambda code updated without re-running synth. We are running synth to have the code updated, the problem is the cloudformation output template should still refer to the lambda file that has been developed instead of the path that it is written (see aws:asset:path):

Metadata:
      aws:cdk:path: shared/kinesis/DataStream/publishKinesisEvents/Resource
      aws:asset:path: /Users/adrian/app-2/packages/service-shared/cdk.out/asset.2bee75b1cdb5b7419c14402cb3dd78ec288cde085122101f6465e4eb1b9429d1
      aws:asset:is-bundled: true
      aws:asset:property: Code

The documentation for cdk synth --staging says:

Copy assets to the output directory (use --no-staging to disable, needed for local debugging the source files with SAM CLI)

And this is not happening. For aws-lambda it works but not for aws-lambda-nodejs as it is the case

@corymhall
Copy link
Contributor

@Sevi7 I'm not super familiar with how SAM CLI works. Does the SAM CLI also perform some bundling? I think the piece that I'm struggling to understand is why you would want it to point to the source code instead of the bundled code.

@corymhall corymhall reopened this Aug 17, 2022
@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 17, 2022
@Sevi7
Copy link

Sevi7 commented Aug 17, 2022

@corymhall For sam local invoke it is not bundling, it is using the template.yaml generated by cdk synth to invoke locally the lambda in order to debug it. We want the lambdas in the template to point to the source code instead of the bundled code so we can use breakpoints in vscode to debug it (it's impossible to debug bundled code)

@bestickley
Copy link

I would like to use this feature for local debugging too with SAM CLI. Any updates @corymhall?

@madeline-k madeline-k added p2 and removed p1 closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. labels Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-nodejs 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

10 participants