You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: do not skip bundling for stacks during CDK Import, otherwise fails (#33322)
### Issues #31999#31677Closes#31999#31677
### Reason for this change
`cdk import` reports changes in the stack when none are present, for NodeJS Lambda functions. This results in the command failing. The only way to work around this is to use the --force flag, which replaces stack resources. This is not ideal as it overwrites existing resources that may contain data, and is just generally unnecessary.
### Description of changes
I added `cdk import` to a configuration that determines which CLI commands bundle code. Before this change, `cdk import` skipped code bundling. This is fine for regular Lambda functions that don't rely on bundling. However, NodeJSFunction does.
The original implementation of skipping bundling for certain CLI commands was introduced via Issue #9540.
`cdk import` was introduced two years later in PR #17666.
### Describe any new or updated permissions being added
No permissions changes.
### Description of how you validated changes
I added an integration test in `packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.nodejs.build.images.ts`.
<img width="757" alt="Screenshot 2025-02-06 at 17 10 41" src="https://github.com/user-attachments/assets/f7b3939f-240c-4021-b0ad-fd7e423e7c09" />
The test ensures that NodeJSFunction Lambdas are always bundled. I will add a canary in a follow-up PR to ensure that new CLI commands are explicitly determined to either need or not need bundling.
I manually validated changes:
1. Created an S3 bucket: `iankhou-1738867338384`
2. Ran `cdk synth`, `cdk deploy` on a stack with a NodeJSFunction, and without an S3 bucket
3. Added code that initializes an S3 bucket and ran `cdk import`
Output and console:
<img width="745" alt="Screenshot 2025-02-06 at 13 45 52" src="https://github.com/user-attachments/assets/c5e4b9ef-ae84-46a4-9b37-a1f58532a00e" />
<img width="1015" alt="Screenshot 2025-02-06 at 13 45 08" src="https://github.com/user-attachments/assets/10298665-281c-4fed-a32b-5c4fbb917f92" />
### Checklist
- [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
0 commit comments