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

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

Closed
plumdog opened this issue Jun 29, 2021 · 5 comments · Fixed by #17210
Closed
Labels
@aws-cdk/aws-lambda-nodejs @aws-cdk/core Related to core CDK functionality bug This issue is a bug. effort/medium Medium work item – several days of effort p1 package/tools Related to AWS CDK Tools or CLI

Comments

@plumdog
Copy link
Contributor

plumdog commented Jun 29, 2021

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 feat(cli): directly deploy stacks in nested assemblies #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

@plumdog plumdog added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 29, 2021
@github-actions github-actions bot added @aws-cdk/aws-lambda-nodejs @aws-cdk/core Related to core CDK functionality package/tools Related to AWS CDK Tools or CLI labels Jun 29, 2021
@rix0rrr
Copy link
Contributor

rix0rrr commented 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.

@rix0rrr rix0rrr added effort/medium Medium work item – several days of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Jul 5, 2021
@rix0rrr rix0rrr removed their assignment Jul 5, 2021
@jogold
Copy link
Contributor

jogold commented Jul 9, 2021

@plumdog I pulled your repo and ran npm run -- cdk synth -e mystage/mystack. I don't get an asset with the whole project in it, instead I don't have the asset at all in the cdk.out.

Looks to me that the -e flag is broken with a stack under a stage but not as you describe it?

@nija-at nija-at removed their assignment Jul 28, 2021
@miekassu
Copy link

possible duplicate #12898

@miekassu
Copy link

@jogold please demo repo desribed in #12898 to reproduce

jogold added a commit to jogold/aws-cdk that referenced this issue Oct 28, 2021
…r stage

We were comparing bundling stacks of the form `Stage/Stack` with stack
names of the form `Stage-Stack`.

Closes aws#12898
Closes aws#15346
jogold added a commit to jogold/aws-cdk that referenced this issue Oct 28, 2021
…r stage

We were comparing bundling stacks of the form `Stage/Stack` with stack
names of the form `Stage-Stack`.

Closes aws#12898
Closes aws#15346
jogold added a commit to jogold/aws-cdk that referenced this issue Oct 28, 2021
…r stage

We were comparing bundling stacks of the form `Stage/Stack` with stack
names of the form `Stage-Stack`.

Closes aws#12898
Closes aws#15346
@mergify mergify bot closed this as completed in #17210 Nov 24, 2021
mergify bot pushed a commit that referenced this issue Nov 24, 2021
…r stage (#17210)

We were comparing bundling stacks of the form `Stage/Stack` with stack
names of the form `Stage-Stack`.

For stacks with `NodejsFunction`s this leads to assets containing the whole CDK project because
when bundling is skipped the asset references the source directory which is the project root.

Closes #12898
Closes #15346


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️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.

beezly pushed a commit to beezly/aws-cdk that referenced this issue Nov 29, 2021
…r stage (aws#17210)

We were comparing bundling stacks of the form `Stage/Stack` with stack
names of the form `Stage-Stack`.

For stacks with `NodejsFunction`s this leads to assets containing the whole CDK project because
when bundling is skipped the asset references the source directory which is the project root.

Closes aws#12898
Closes aws#15346


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
…r stage (aws#17210)

We were comparing bundling stacks of the form `Stage/Stack` with stack
names of the form `Stage-Stack`.

For stacks with `NodejsFunction`s this leads to assets containing the whole CDK project because
when bundling is skipped the asset references the source directory which is the project root.

Closes aws#12898
Closes aws#15346


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-nodejs @aws-cdk/core Related to core CDK functionality bug This issue is a bug. effort/medium Medium work item – several days of effort p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants