question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(core/aws-lambda-nodejs/cli): confusing NodejsFunction+Stage+exclusive-cli-flag behaviour

See original GitHub issue

When deploying using all of the following, the asset for the Lambda function is a zip of the root of the project, not the asset as expected:

  • a stack containing a @aws-cdk/aws-lambda-nodejs.NodejsFunction Lambda function
  • attaching the stack I’m deploying to a @aws-cdk/core.Stage rather than to a @aws-cdk/core.App
  • using the -e (exclusive) flag to the synth or deploy commands

Based on my testing, not doing any one of these things results in the expected behaviour where the asset is the expected thing.

See dummy project here https://github.com/isotoma/cdk-nodejsfunction-asset-size-debugging to show my testing and why I have ended up where I have.

I happened to find this because a real project uploaded the whole project root as the source asset for the Lambda, which ended up being over Lambda’s 250MB limit.

Reproduction Steps

See https://github.com/isotoma/cdk-nodejsfunction-asset-size-debugging, and the branches listed in the readme, and the behaviour shown in the Github CI.

What did you expect to happen?

  • Use of the -e CLI flag should not affect the built asset
  • Use of a Stage should not affect the built asset

What actually happened?

  • I would not expect the whole project directory to ever be zipped and uploaded to the assets bucket.

Environment

  • CDK CLI Version : 1.110.1 (also affects >= 1.102.0, because that’s where the feature to deploy stacks from stages arrived, see https://github.com/aws/aws-cdk/pull/14379. Believe earlier versions did not have this feature.)
  • Framework Version: 1.110.1
  • Node.js Version: v14.17.0
  • OS: Linux
  • Language (Version): Typescript 4

Other

I am mildly suspicious of switches in context in cdk.json, but for no real reason, and have no guesses as to what might actually be wrong.

Happy to try other things with my dummy project if useful.


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rix0rrrcommented, Jul 5, 2021

Thanks for the detailed investigation! Unfortunately we ourselves might not be able to get to this quickly, as there are many issues competing for our attention. I hope @jogold has some spare cycles to investigate, otherwise please collect upvotes on this issue to raise the priority.

0reactions
github-actions[bot]commented, Nov 24, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

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. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found