From 84c03676c6034e70e2d7ab449cf63f903d97f1ff Mon Sep 17 00:00:00 2001 From: Calvin Combs Date: Wed, 17 Jan 2024 08:59:47 -0800 Subject: [PATCH 1/4] messaging --- packages/aws-cdk/lib/api/util/cloudformation.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk/lib/api/util/cloudformation.ts b/packages/aws-cdk/lib/api/util/cloudformation.ts index 18f627fe8c1d0..5a84da75fdb17 100644 --- a/packages/aws-cdk/lib/api/util/cloudformation.ts +++ b/packages/aws-cdk/lib/api/util/cloudformation.ts @@ -315,9 +315,9 @@ export async function createDiffChangeSet(options: PrepareChangeSetOptions): Pro for (const resource of Object.values((options.stack.template.Resources ?? {}))) { if ((resource as any).Type === 'AWS::CloudFormation::Stack') { // eslint-disable-next-line no-console - debug('This stack contains one or more nested stacks, falling back to no change set diff...'); + debug('This stack contains one or more nested stacks, falling back to template-only diff...'); - return undefined; + //return undefined; } } @@ -337,7 +337,7 @@ async function uploadBodyParameterAndCreateChangeSet(options: PrepareChangeSetOp const cfn = preparedSdk.stackSdk.cloudFormation(); const exists = (await CloudFormationStack.lookup(cfn, options.stack.stackName, false)).exists; - options.stream.write('Creating a change set, this may take a while...\n'); + options.stream.write('Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)\n'); return await createChangeSet({ cfn, changeSetName: 'cdk-diff-change-set', @@ -349,8 +349,8 @@ async function uploadBodyParameterAndCreateChangeSet(options: PrepareChangeSetOp parameters: options.parameters, }); } catch (e: any) { - // eslint-disable-next-line no-console - console.error(`Failed to create change set with error: '${e.message}', falling back to no change-set diff`); + debug(e.message); + options.stream.write('Could not create a change set, will base the diff on template differences (run again with -v to see the reason)'); return undefined; } From bf1e65ba213ece99510fb5b3856f30ddc395e1d0 Mon Sep 17 00:00:00 2001 From: Calvin Combs Date: Wed, 17 Jan 2024 09:02:46 -0800 Subject: [PATCH 2/4] fix --- packages/aws-cdk/lib/api/util/cloudformation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/api/util/cloudformation.ts b/packages/aws-cdk/lib/api/util/cloudformation.ts index 5a84da75fdb17..4c10aeed9c82a 100644 --- a/packages/aws-cdk/lib/api/util/cloudformation.ts +++ b/packages/aws-cdk/lib/api/util/cloudformation.ts @@ -317,7 +317,7 @@ export async function createDiffChangeSet(options: PrepareChangeSetOptions): Pro // eslint-disable-next-line no-console debug('This stack contains one or more nested stacks, falling back to template-only diff...'); - //return undefined; + return undefined; } } From 5ba94b5fb93c27b4bff355b3c73aa792bac9cc7a Mon Sep 17 00:00:00 2001 From: Calvin Combs Date: Wed, 17 Jan 2024 09:06:35 -0800 Subject: [PATCH 3/4] newline --- packages/aws-cdk/lib/api/util/cloudformation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/lib/api/util/cloudformation.ts b/packages/aws-cdk/lib/api/util/cloudformation.ts index 4c10aeed9c82a..7c95cbbc7ec49 100644 --- a/packages/aws-cdk/lib/api/util/cloudformation.ts +++ b/packages/aws-cdk/lib/api/util/cloudformation.ts @@ -317,7 +317,7 @@ export async function createDiffChangeSet(options: PrepareChangeSetOptions): Pro // eslint-disable-next-line no-console debug('This stack contains one or more nested stacks, falling back to template-only diff...'); - return undefined; + //return undefined; } } @@ -350,7 +350,7 @@ async function uploadBodyParameterAndCreateChangeSet(options: PrepareChangeSetOp }); } catch (e: any) { debug(e.message); - options.stream.write('Could not create a change set, will base the diff on template differences (run again with -v to see the reason)'); + options.stream.write('Could not create a change set, will base the diff on template differences (run again with -v to see the reason)\n'); return undefined; } From a4e6d5c828834d99d22b15bc420901b4e6d28291 Mon Sep 17 00:00:00 2001 From: Calvin Combs Date: Thu, 18 Jan 2024 12:34:15 -0800 Subject: [PATCH 4/4] test --- packages/aws-cdk/test/diff.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/aws-cdk/test/diff.test.ts b/packages/aws-cdk/test/diff.test.ts index a7b5905e12f87..85f60c7d42f3d 100644 --- a/packages/aws-cdk/test/diff.test.ts +++ b/packages/aws-cdk/test/diff.test.ts @@ -350,6 +350,7 @@ Resources const plainTextOutput = buffer.data.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, '') .replace(/[ \t]+$/mg, ''); expect(plainTextOutput.trim()).toEqual(`Stack Parent +Could not create a change set, will base the diff on template differences (run again with -v to see the reason) Resources [~] AWS::CloudFormation::Stack AdditionChild └─ [~] Resources