From befd35649c8c5f8091c7308687c47b7aca31082d Mon Sep 17 00:00:00 2001 From: aws-amplify-bot Date: Fri, 1 May 2026 15:28:27 -0400 Subject: [PATCH 1/6] recommend drift aware --- .../@aws-cdk/toolkit-lib/lib/api/deployments/deploy-stack.ts | 3 +++ 1 file changed, 3 insertions(+) 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..df612bb97 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 @@ -342,6 +342,9 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe options.sdk.appendCustomUserAgent('cdk-hotswap/fallback'); deploymentMethod = deploymentMethod.fallback; } else { + await ioHelper.defaults.info(format( + `Your next regular deployment with ${stackEnv.name} should use 'cdk deploy --revert-drift' to resolve the drift you introduced while hotswapping.` + )); return { type: 'did-deploy-stack', noOp: true, From 15ff841e79297b222cffda6aa28284ca6456249b Mon Sep 17 00:00:00 2001 From: aws-amplify-bot Date: Fri, 1 May 2026 15:34:37 -0400 Subject: [PATCH 2/6] phrasing --- .../@aws-cdk/toolkit-lib/lib/api/deployments/deploy-stack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 df612bb97..1da559701 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 @@ -343,7 +343,7 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe deploymentMethod = deploymentMethod.fallback; } else { await ioHelper.defaults.info(format( - `Your next regular deployment with ${stackEnv.name} should use 'cdk deploy --revert-drift' to resolve the drift you introduced while hotswapping.` + `Your next regular deployment with ${stackEnv.name} should use 'cdk deploy --revert-drift' to resolve the drift that was introduced while hotswapping.` )); return { type: 'did-deploy-stack', From 3d6ef1dd564d76e078159916bae8e2a625fc9a40 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 May 2026 19:42:45 +0000 Subject: [PATCH 3/6] chore: self mutation Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../@aws-cdk/toolkit-lib/lib/api/deployments/deploy-stack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1da559701..bd56276e1 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 @@ -343,7 +343,7 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe deploymentMethod = deploymentMethod.fallback; } else { await ioHelper.defaults.info(format( - `Your next regular deployment with ${stackEnv.name} should use 'cdk deploy --revert-drift' to resolve the drift that was introduced while hotswapping.` + `Your next regular deployment with ${stackEnv.name} should use 'cdk deploy --revert-drift' to resolve the drift that was introduced while hotswapping.`, )); return { type: 'did-deploy-stack', From 454b2450fa61e45ac3614665f50a4366e15875f1 Mon Sep 17 00:00:00 2001 From: aws-amplify-bot Date: Fri, 1 May 2026 16:13:02 -0400 Subject: [PATCH 4/6] fix --- .../@aws-cdk/toolkit-lib/lib/api/deployments/deploy-stack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1da559701..bd56276e1 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 @@ -343,7 +343,7 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe deploymentMethod = deploymentMethod.fallback; } else { await ioHelper.defaults.info(format( - `Your next regular deployment with ${stackEnv.name} should use 'cdk deploy --revert-drift' to resolve the drift that was introduced while hotswapping.` + `Your next regular deployment with ${stackEnv.name} should use 'cdk deploy --revert-drift' to resolve the drift that was introduced while hotswapping.`, )); return { type: 'did-deploy-stack', From e3d00efa188f4cd210907fa00c0482ceb77d494b Mon Sep 17 00:00:00 2001 From: aws-amplify-bot Date: Fri, 1 May 2026 17:06:42 -0400 Subject: [PATCH 5/6] updates --- .../lib/api/deployments/deploy-stack.ts | 8 +++++--- .../test/api/deployments/deploy-stack.test.ts | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) 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 bd56276e1..9dbad5597 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,11 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe ); if (hotswapDeploymentResult) { + if (deploymentMethod.fallback) { + await ioHelper.defaults.info( + `Your next CloudFormation deployment with ${stackEnv.name} should use 'cdk deploy --revert-drift' to resolve the drift that was introduced while hotswapping.`, + ); + } return hotswapDeploymentResult; } @@ -342,9 +347,6 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe options.sdk.appendCustomUserAgent('cdk-hotswap/fallback'); deploymentMethod = deploymentMethod.fallback; } else { - await ioHelper.defaults.info(format( - `Your next regular deployment with ${stackEnv.name} should use 'cdk deploy --revert-drift' to resolve the drift that was introduced while hotswapping.`, - )); return { type: 'did-deploy-stack', noOp: true, 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..4fd0aa3cc 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 with fallback', async () => { + givenStackExists(); + (tryHotswapDeployment as jest.Mock).mockResolvedValue({ + type: 'did-deploy-stack', noOp: false, stackArn: 'arn:stack', outputs: {}, + }); + + // WHEN + await testDeployStack({ + ...standardDeployStackArguments(), + deploymentMethod: { method: 'hotswap', fallback: { method: 'change-set' } }, + }); + + // THEN + expect(ioHost.notifySpy).toHaveBeenCalledWith(expect.objectContaining({ + message: expect.stringMatching(/should use 'cdk deploy --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 From ef181ff66fe5b33e7b6ad1d5c0408ce941ab636d Mon Sep 17 00:00:00 2001 From: aws-amplify-bot Date: Mon, 4 May 2026 11:15:04 -0400 Subject: [PATCH 6/6] fix when message appears - should not just be when fallback is configured --- .../toolkit-lib/lib/api/deployments/deploy-stack.ts | 8 +++----- .../toolkit-lib/test/api/deployments/deploy-stack.test.ts | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) 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 9dbad5597..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,11 +320,9 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe ); if (hotswapDeploymentResult) { - if (deploymentMethod.fallback) { - await ioHelper.defaults.info( - `Your next CloudFormation deployment with ${stackEnv.name} should use 'cdk deploy --revert-drift' to resolve the drift that was introduced while hotswapping.`, - ); - } + 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 4fd0aa3cc..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,7 +240,7 @@ test('correctly passes SSM parameters when hotswapping', async () => { ); }); -test('prints revert-drift recommendation on successful hotswap deployment with fallback', 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: {}, @@ -249,12 +249,12 @@ test('prints revert-drift recommendation on successful hotswap deployment with f // WHEN await testDeployStack({ ...standardDeployStackArguments(), - deploymentMethod: { method: 'hotswap', fallback: { method: 'change-set' } }, + deploymentMethod: { method: 'hotswap' }, }); // THEN expect(ioHost.notifySpy).toHaveBeenCalledWith(expect.objectContaining({ - message: expect.stringMatching(/should use 'cdk deploy --revert-drift' to resolve the drift that was introduced while hotswapping/), + message: expect.stringMatching(/should include '--revert-drift' to resolve the drift that was introduced while hotswapping/), })); });