Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions packages/@aws-cdk/cloudformation-diff/test/diff-template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something but I'm not sure how this tests that we do not do a changeset for new stacks. Could you clarify that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was confused on this too - my logic was that calling fullDiff with the current stack being empty (new) should mean that there should be only 1 difference count, and the change impact should be ResourceImpact.WILL_CREATE; I'm not sure how else to test that we don't do changeset for new stacks

// 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);
});
});