diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/deployments/deploy-stack.ts b/packages/@aws-cdk/toolkit-lib/lib/api/deployments/deploy-stack.ts index 701bfcd53..8b6623c3d 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/deployments/deploy-stack.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/deployments/deploy-stack.ts @@ -320,6 +320,9 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe ); if (hotswapDeploymentResult) { + await ioHelper.defaults.info( + `Your next non-hotswap deployment with ${stackEnv.name} should include '--revert-drift' to resolve the drift that was introduced while hotswapping.`, + ); return hotswapDeploymentResult; } diff --git a/packages/@aws-cdk/toolkit-lib/test/api/deployments/deploy-stack.test.ts b/packages/@aws-cdk/toolkit-lib/test/api/deployments/deploy-stack.test.ts index 982be19d8..5929c4397 100644 --- a/packages/@aws-cdk/toolkit-lib/test/api/deployments/deploy-stack.test.ts +++ b/packages/@aws-cdk/toolkit-lib/test/api/deployments/deploy-stack.test.ts @@ -240,6 +240,24 @@ test('correctly passes SSM parameters when hotswapping', async () => { ); }); +test('prints revert-drift recommendation on successful hotswap deployment', async () => { + givenStackExists(); + (tryHotswapDeployment as jest.Mock).mockResolvedValue({ + type: 'did-deploy-stack', noOp: false, stackArn: 'arn:stack', outputs: {}, + }); + + // WHEN + await testDeployStack({ + ...standardDeployStackArguments(), + deploymentMethod: { method: 'hotswap' }, + }); + + // THEN + expect(ioHost.notifySpy).toHaveBeenCalledWith(expect.objectContaining({ + message: expect.stringMatching(/should include '--revert-drift' to resolve the drift that was introduced while hotswapping/), + })); +}); + describe('hotswap template cache', () => { test('writeHotswapTemplateCache is called on a successful hotswap deployment', async () => { // GIVEN