aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.71k stars 3.93k forks source link

(cli): import is not using a custom qualifier #32278

Open moltar opened 1 day ago

moltar commented 1 day ago

Describe the bug

Similar to #29179, cdk import ignores qualifier set in the cdk.json context and tries to use defaults.

Which results in a failure.

Supplying the stack name fixes the problem, but it's not a scalable approach.

Regression Issue

Last Known Working CDK Version

2.171.0

Expected Behavior

cdk import to respect the qualifier.

Current Behavior

Does not respect the qualifier.

Reproduction Steps

Use a custom qualifier.

Try to do an import with a large template.

Get an error:

❌ my-stack-name failed: Error: Template too large to deploy ("cdk bootstrap" is required)

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.171.0

Framework Version

No response

Node.js Version

22

OS

macOs

Language

TypeScript

Language Version

No response

Other information

No response

ashishdhingra commented 19 hours ago

@moltar Good afternoon. Somehow, I'm unable to reproduce the issue using cdk import to import resources that generate more than 50KB of CloudFormation template. Used version 2.171.0 of aws-cdk-lib and CDK CLI. STEPS:

Please let me know if I'm missing anything. Did you also update the version of CDK CLI using command sudo npm install -g aws-cdk@latest?

Thanks, Ashish

moltar commented 12 hours ago

Hi @ashishdhingra thank you for the repro steps.

I think the bootstrap stack name plays a role too.

In your repro, you still used the default one (CDKToolkit) which I'm guessing CDK then uses to find/infer some knowledge.

I use a different stack name. And what fixed the import for me was to explicitly set the stack name as the CLI option.

But IMO that should be unnecessary as there's nothing that CDK should need from that stack. Everything it needs to do the work is based on well known resource names based on the qualifier.