Open moltar opened 1 day 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:
ap-south-1
using custom qualifier cdk bootstrap aws://<<ACCOUNT-ID>>/ap-south-1 --qualifier abcdefghi
.cdk.json
to add "@aws-cdk/core:bootstrapQualifier": "abcdefghi"
context key.for i in {1..150}; do aws iam create-role --assume-role-policy-document file://comprehend-trust-policy.json --role-name testrole$i; done
.for i in {1..150}; do echo "new iam.Role(this, 'testrole$i', { roleName: 'testrole$i', assumedBy: new iam.ServicePrincipal('comprehend.amazonaws.com')});"; done
, generated the TypeScript code.Ensured that bin/cskstack.ts during app creation, region
is set to ap-south-1
.
#!/usr/bin/env node
import * as cdk from 'aws-cdk-lib';
import { CdkimportCustomqualifierStack } from '../lib/cdkimport_customqualifier-stack';
const app = new cdk.App();
new CdkimportCustomqualifierStack(app, 'CdkimportCustomqualifierStack', {
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'ap-south-1'}, //process.env.CDK_DEFAULT_REGION },
});
cdk import
.
68.6 KB
.cdk import
is successful.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
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.
Describe the bug
Similar to #29179,
cdk import
ignores qualifier set in thecdk.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:
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