Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@ class FullCloudFormationDeployment {
StackName: this.stackName,
EnableTerminationProtection: terminationProtection,
});
await this.ioHelper.defaults.debug(format('Termination protection updated to %s for stack %s', terminationProtection, this.stackName));
// Report this at info level: if the change set turns out to be empty, this is the only change the deployment makes
await this.ioHelper.defaults.info(format('%s: termination protection %s', chalk.bold(this.stackName), terminationProtection ? 'enabled' : 'disabled'));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,51 @@ test('updateTerminationProtection called when termination protection is undefine
});
});

test.each([
['change-set' as const],
['direct' as const],
])('termination protection change is reported when it is the only change (method=%s)', async (method) => {
// GIVEN
givenStackExists({ EnableTerminationProtection: true });
givenTemplateIs(defaultTargetTemplate());
givenCurrentChangeSetIsEmpty();
if (method === 'direct') {
mockCloudFormationClient.on(UpdateStackCommand).rejects(new Error('No updates are to be performed.'));
}

// WHEN
const ret = await testDeployStack({
...standardDeployStackArguments(),
deploymentMethod: { method },
});

// THEN
expect(mockCloudFormationClient).toHaveReceivedCommandWith(UpdateTerminationProtectionCommand, {
StackName: 'withouterrors',
EnableTerminationProtection: false,
});
expect(ret).toEqual(expect.objectContaining({ noOp: true }));
ioHost.expectMessage({ containing: 'termination protection disabled', level: 'info' });
});

test('termination protection is not reported when it does not change', async () => {
// GIVEN
givenStackExists();
givenCurrentChangeSetIsEmpty();

// WHEN
await testDeployStack({
...standardDeployStackArguments(),
forceDeployment: true,
});

// THEN
expect(mockCloudFormationClient).not.toHaveReceivedCommand(UpdateTerminationProtectionCommand);
expect(ioHost.notifySpy).not.toHaveBeenCalledWith(expect.objectContaining({
message: expect.stringContaining('termination protection'),
}));
});

describe('disable rollback', () => {
test('by default, we do not disable rollback (and also do not pass the flag)', async () => {
// WHEN
Expand Down
Loading