You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cdk): cdk diff --quiet to print stack name when there is diffs (#30186)
### Issue # (if applicable)
Closes#27128
### Reason for this change
The `--quiet` flag on the `cdk diff` command prevents the stack name and default message from being printed when no diff exists.
If diffs exist, the stack name and diffs are expected to be printed, but currently, the stack name is not printed, and it is difficult to determine which stack the diff is for.
for example:
```bash
$ cdk diff --quiet
Resources
[~] AWS::S3::Bucket MyFirstBucket MyFirstBucketB8884501
├─ [~] DeletionPolicy
│ ├─ [-] Delete
│ └─ [+] Retain
└─ [~] UpdateReplacePolicy
├─ [-] Delete
└─ [+] Retain
✨ Number of stacks with differences: 1
```
This PR will fix to print the stack name when the `--quiet` flag is specified and diffs exist.
### Description of changes
Changed the position of the `fullDiff` function call.
It is possible to output the stack name in the `printSecurityDiff` or `printStackDiff` functions, but since the message has already been output before these functions are called, the stack name must be output first.
I think it would be more user-friendly to have all messages after the output of the stack name, but if this is not the case, please point this out.
### Description of how you validated changes
I added a unit test to confirm to print the stack name when diff exists.
### 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*
stream.write('Checking if the stack exists before creating the changeset has failed, will base the diff on template differences (run again with -v to see the reason)\n');
169
+
if(!quiet){
170
+
stream.write(`Checking if the stack ${stack.stackName} exists before creating the changeset has failed, will base the diff on template differences (run again with -v to see the reason)\n`);
171
+
}
174
172
stackExists=false;
175
173
}
176
174
@@ -190,14 +188,12 @@ export class CdkToolkit {
190
188
}
191
189
}
192
190
193
-
if(resourcesToImport){
194
-
stream.write('Parameters and rules created during migration do not affect resource configuration.\n');
warning(`This deployment will make potentially sensitive changes according to your current security approval level (--require-approval ${requireApproval}).`);
0 commit comments