From 21397e64cc671ee566b6f5b2debff37dbd5c138b Mon Sep 17 00:00:00 2001 From: Momo Kornher Date: Wed, 12 Feb 2025 22:37:03 +0000 Subject: [PATCH] remove unused toolkitStackName --- packages/@aws-cdk/toolkit/lib/toolkit/toolkit.ts | 5 +---- .../aws-cdk/lib/api/resource-import/importer.ts | 15 ++++++--------- .../aws-cdk/lib/api/resource-import/migrator.ts | 1 - packages/aws-cdk/lib/cli/cdk-toolkit.ts | 1 - .../test/api/resource-import/import.test.ts | 8 ++------ 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/packages/@aws-cdk/toolkit/lib/toolkit/toolkit.ts b/packages/@aws-cdk/toolkit/lib/toolkit/toolkit.ts index 55851c672fd92..8a92814553896 100644 --- a/packages/@aws-cdk/toolkit/lib/toolkit/toolkit.ts +++ b/packages/@aws-cdk/toolkit/lib/toolkit/toolkit.ts @@ -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; diff --git a/packages/aws-cdk/lib/api/resource-import/importer.ts b/packages/aws-cdk/lib/api/resource-import/importer.ts index f55af430f8a05..65e81a7f3454e 100644 --- a/packages/aws-cdk/lib/api/resource-import/importer.ts +++ b/packages/aws-cdk/lib/api/resource-import/importer.ts @@ -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 * @@ -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[]; @@ -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); @@ -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); diff --git a/packages/aws-cdk/lib/api/resource-import/migrator.ts b/packages/aws-cdk/lib/api/resource-import/migrator.ts index f652d4be9761f..60d91f85d5980 100644 --- a/packages/aws-cdk/lib/api/resource-import/migrator.ts +++ b/packages/aws-cdk/lib/api/resource-import/migrator.ts @@ -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, diff --git a/packages/aws-cdk/lib/cli/cdk-toolkit.ts b/packages/aws-cdk/lib/cli/cdk-toolkit.ts index 6f38cc77ddd32..ec25931ca1d1b 100644 --- a/packages/aws-cdk/lib/cli/cdk-toolkit.ts +++ b/packages/aws-cdk/lib/cli/cdk-toolkit.ts @@ -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, diff --git a/packages/aws-cdk/test/api/resource-import/import.test.ts b/packages/aws-cdk/test/api/resource-import/import.test.ts index 258246536e65f..046e4170b92f7 100644 --- a/packages/aws-cdk/test/api/resource-import/import.test.ts +++ b/packages/aws-cdk/test/api/resource-import/import.test.ts @@ -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), @@ -384,9 +382,7 @@ async function importTemplateFromClean(stack: ReturnType) { 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; }