Skip to content

Commit

Permalink
remove unused toolkitStackName
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Feb 12, 2025
1 parent 4fcc061 commit 21397e6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 21 deletions.
5 changes: 1 addition & 4 deletions packages/@aws-cdk/toolkit/lib/toolkit/toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,7 @@ export class Toolkit extends CloudAssemblySourceBuilder implements AsyncDisposab
const deployments = await this.deploymentsForAction('deploy');
const migrator = new ResourceMigrator({ deployments, ioHost, action });

await migrator.tryMigrateResources(stackCollection, {
toolkitStackName: this.toolkitStackName,
...options,
});
await migrator.tryMigrateResources(stackCollection, options);

const requireApproval = options.requireApproval ?? RequireApproval.NEVER;

Expand Down
15 changes: 6 additions & 9 deletions packages/aws-cdk/lib/api/resource-import/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ export interface ResourceImporterProps {
}

export interface ImportDeploymentOptions {
/**
* Name of the toolkit stack to use/deploy
*
* @default CDKToolkit
*/
readonly toolkitStackName: string;

/**
* Role to pass to CloudFormation for deployment
*
Expand All @@ -35,11 +28,15 @@ export interface ImportDeploymentOptions {

/**
* Deployment method
*
* @default - Change set with default options
*/
readonly deploymentMethod?: DeploymentMethod;

/**
* Stack tags (pass through to CloudFormation)
*
* @default - No tags
*/
readonly tags?: Tag[];

Expand Down Expand Up @@ -183,7 +180,7 @@ export class ResourceImporter {
* @param importMap Mapping from CDK construct tree path to physical resource import identifiers
* @param options Options to pass to CloudFormation deploy operation
*/
public async importResourcesFromMap(importMap: ImportMap, options: ImportDeploymentOptions) {
public async importResourcesFromMap(importMap: ImportMap, options: ImportDeploymentOptions = {}) {
const resourcesToImport: ResourcesToImport = await this.makeResourcesToImport(importMap);
const updatedTemplate = await this.currentTemplateWithAdditions(importMap.importResources);

Expand All @@ -198,7 +195,7 @@ export class ResourceImporter {
* @param resourcesToImport The mapping created by cdk migrate
* @param options Options to pass to CloudFormation deploy operation
*/
public async importResourcesFromMigrate(resourcesToImport: ResourcesToImport, options: ImportDeploymentOptions) {
public async importResourcesFromMigrate(resourcesToImport: ResourcesToImport, options: ImportDeploymentOptions = {}) {
const updatedTemplate = this.removeNonImportResources();

await this.importResources(updatedTemplate, resourcesToImport, options);
Expand Down
1 change: 0 additions & 1 deletion packages/aws-cdk/lib/api/resource-import/migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export class ResourceMigrator {
// Initial Deployment
await migrateDeployment.importResourcesFromMigrate(resourcesToImport, {
roleArn: options.roleArn,
toolkitStackName: options.toolkitStackName,
deploymentMethod: options.deploymentMethod,
usePreviousParameters: true,
progress: options.progress,
Expand Down
1 change: 0 additions & 1 deletion packages/aws-cdk/lib/cli/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,6 @@ export class CdkToolkit {
const tags = tagsForStack(stack);
await resourceImporter.importResourcesFromMap(actualImport, {
roleArn: options.roleArn,
toolkitStackName: options.toolkitStackName ?? this.toolkitStackName,
tags,
deploymentMethod: options.deploymentMethod,
usePreviousParameters: true,
Expand Down
8 changes: 2 additions & 6 deletions packages/aws-cdk/test/api/resource-import/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ test('asks human to confirm automic import if identifier is in template', async
};

// WHEN
await importer.importResourcesFromMap(importMap, {
toolkitStackName: 'CDKToolkit',
});
await importer.importResourcesFromMap(importMap);

expect(mockCloudFormationClient).toHaveReceivedCommandWith(CreateChangeSetCommand, {
ChangeSetName: expect.any(String),
Expand Down Expand Up @@ -384,9 +382,7 @@ async function importTemplateFromClean(stack: ReturnType<typeof testStack>) {
const importer = new ResourceImporter(stack, props);
const { additions } = await importer.discoverImportableResources();
const importable = await importer.askForResourceIdentifiers(additions);
await importer.importResourcesFromMap(importable, {
toolkitStackName: 'CDKToolkit',
});
await importer.importResourcesFromMap(importable);
return importable;
}

Expand Down

0 comments on commit 21397e6

Please sign in to comment.