diff --git a/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts b/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts index 734753b1d7fc9..71117ea7758bb 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts @@ -51,9 +51,12 @@ export function fullDiff( normalize(currentTemplate); normalize(newTemplate); const theDiff = diffTemplate(currentTemplate, newTemplate); + // If the currentTemplate is empty, we skip these changeset functions. if (changeSet) { - filterFalsePositivies(theDiff, changeSet); addImportInformation(theDiff, changeSet); + if (Object.keys(currentTemplate).length > 0) { + filterFalsePositivies(theDiff, changeSet); + } } return theDiff; diff --git a/packages/@aws-cdk/cloudformation-diff/test/diff-template.test.ts b/packages/@aws-cdk/cloudformation-diff/test/diff-template.test.ts index 4d97244803254..51a0536940d1c 100644 --- a/packages/@aws-cdk/cloudformation-diff/test/diff-template.test.ts +++ b/packages/@aws-cdk/cloudformation-diff/test/diff-template.test.ts @@ -1231,4 +1231,22 @@ describe('changeset', () => { expect(differences.resources.differenceCount).toBe(1); expect(differences.resources.get('BucketResource').changeImpact === ResourceImpact.WILL_IMPORT); }); + + test('does not do changeset checks for new stack', async () => { + // GIVEN + const currentTemplate = {}; + + // WHEN + const newTemplate = { + Resources: { + NewResource: { + Type: 'AWS::Something::Resource', + }, + }, + }; + + let differences = fullDiff(currentTemplate, newTemplate); + expect(differences.resources.differenceCount).toBe(1); + expect(differences.resources.get('NewResource').changeImpact).toBe(ResourceImpact.WILL_CREATE); + }); });