From 2126ee5b1eac4bce2d085b1a9bd27a65eb33b137 Mon Sep 17 00:00:00 2001
From: Calvin Combs <66279577+comcalvi@users.noreply.github.com>
Date: Fri, 19 Apr 2024 14:00:02 -0700
Subject: [PATCH] fix(CLI): bootstrap shows no hotswap changes when there are
 no changes (#29877)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

### Issue # (if applicable)

Closes #25736.

### Reason for this change

The bootstrap calls `deployStack` without specifying hotswap, and `deployStack` does not correctly default the hotswap mode to `FULL_DEPLOYMENT`.

### Description of changes

Make `deployStack` correctly default `hotswapMode` to `FULL_DEPLOYMENT`.

### Description of how you validated changes

Manual testing. Before this change:

```
 ✨ hotswap deployment skipped - no changes were detected (use --force to override)

 ✅  Environment aws://123456789012/us-east-1 bootstrapped (no changes).

```

After:

```
 ✅  Environment aws://123456789012/us-east-1 bootstrapped (no changes).
```

Unit tests not added because we don't have any unit tests for bootstrap and this is cosmetic.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
---
 packages/aws-cdk/lib/api/deploy-stack.ts | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/packages/aws-cdk/lib/api/deploy-stack.ts b/packages/aws-cdk/lib/api/deploy-stack.ts
index 8e1c8f55e7ba8..28af2d39616b0 100644
--- a/packages/aws-cdk/lib/api/deploy-stack.ts
+++ b/packages/aws-cdk/lib/api/deploy-stack.ts
@@ -262,11 +262,13 @@ export async function deployStack(options: DeployStackOptions): Promise<DeploySt
     ? templateParams.updateExisting(finalParameterValues, cloudFormationStack.parameters)
     : templateParams.supplyAll(finalParameterValues);
 
+  const hotswapMode = options.hotswap ?? HotswapMode.FULL_DEPLOYMENT;
+
   if (await canSkipDeploy(options, cloudFormationStack, stackParams.hasChanges(cloudFormationStack.parameters))) {
     debug(`${deployName}: skipping deployment (use --force to override)`);
     // if we can skip deployment and we are performing a hotswap, let the user know
     // that no hotswap deployment happened
-    if (options.hotswap !== HotswapMode.FULL_DEPLOYMENT) {
+    if (hotswapMode !== HotswapMode.FULL_DEPLOYMENT) {
       print(`\n ${ICON} %s\n`, chalk.bold('hotswap deployment skipped - no changes were detected (use --force to override)'));
     }
     return {
@@ -289,8 +291,7 @@ export async function deployStack(options: DeployStackOptions): Promise<DeploySt
     parallel: options.assetParallelism,
   });
 
-  const hotswapMode = options.hotswap;
-  if (hotswapMode && hotswapMode !== HotswapMode.FULL_DEPLOYMENT) {
+  if (hotswapMode !== HotswapMode.FULL_DEPLOYMENT) {
     // attempt to short-circuit the deployment if possible
     try {
       const hotswapDeploymentResult = await tryHotswapDeployment(