@@ -110,7 +110,7 @@ export async function tryHotswapDeployment(
110
110
hotswapPropertyOverrides ,
111
111
) ;
112
112
113
- await hotswapSpan . end ( ) ;
113
+ await hotswapSpan . end ( result ) ;
114
114
115
115
if ( result ?. hotswapped === true ) {
116
116
return {
@@ -135,7 +135,7 @@ async function hotswapDeployment(
135
135
stack : cxapi . CloudFormationStackArtifact ,
136
136
hotswapMode : HotswapMode ,
137
137
hotswapPropertyOverrides : HotswapPropertyOverrides ,
138
- ) : Promise < HotswapResult > {
138
+ ) : Promise < Omit < HotswapResult , 'duration' > > {
139
139
// resolve the environment, so we can substitute things like AWS::Region in CFN expressions
140
140
const resolvedEnv = await sdkProvider . resolveEnvironment ( stack . environment ) ;
141
141
// create a new SDK using the CLI credentials, because the default one will not work for new-style synthesis -
@@ -162,11 +162,18 @@ async function hotswapDeployment(
162
162
currentTemplate . nestedStacks , hotswapPropertyOverrides ,
163
163
) ;
164
164
165
- await logNonHotswappableChanges ( ioSpan , nonHotswappable , hotswapMode ) ;
165
+ await logRejectedChanges ( ioSpan , nonHotswappable , hotswapMode ) ;
166
166
167
167
const hotswappableChanges = hotswappable . map ( o => o . change ) ;
168
168
const nonHotswappableChanges = nonHotswappable . map ( n => n . change ) ;
169
169
170
+ await ioSpan . notify ( IO . CDK_TOOLKIT_I5401 . msg ( 'Hotswap plan created' , {
171
+ stack,
172
+ mode : hotswapMode ,
173
+ hotswappableChanges,
174
+ nonHotswappableChanges,
175
+ } ) ) ;
176
+
170
177
// preserve classic hotswap behavior
171
178
if ( hotswapMode === 'fall-back' ) {
172
179
if ( nonHotswappableChanges . length > 0 ) {
@@ -181,7 +188,7 @@ async function hotswapDeployment(
181
188
}
182
189
183
190
// apply the short-circuitable changes
184
- await applyAllHotswappableChanges ( sdk , ioSpan , hotswappable ) ;
191
+ await applyAllHotswapOperations ( sdk , ioSpan , hotswappable ) ;
185
192
186
193
return {
187
194
stack,
@@ -489,27 +496,29 @@ function isCandidateForHotswapping(
489
496
} ;
490
497
}
491
498
492
- async function applyAllHotswappableChanges ( sdk : SDK , ioSpan : IMessageSpan < any > , hotswappableChanges : HotswapOperation [ ] ) : Promise < void [ ] > {
493
- if ( hotswappableChanges . length > 0 ) {
494
- await ioSpan . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( `\n ${ ICON } hotswapping resources:` ) ) ;
499
+ async function applyAllHotswapOperations ( sdk : SDK , ioSpan : IMessageSpan < any > , hotswappableChanges : HotswapOperation [ ] ) : Promise < void [ ] > {
500
+ if ( hotswappableChanges . length === 0 ) {
501
+ return Promise . resolve ( [ ] ) ;
495
502
}
503
+
504
+ await ioSpan . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( `\n${ ICON } hotswapping resources:` ) ) ;
496
505
const limit = pLimit ( 10 ) ;
497
506
// eslint-disable-next-line @cdklabs/promiseall-no-unbounded-parallelism
498
507
return Promise . all ( hotswappableChanges . map ( hotswapOperation => limit ( ( ) => {
499
- return applyHotswappableChange ( sdk , ioSpan , hotswapOperation ) ;
508
+ return applyHotswapOperation ( sdk , ioSpan , hotswapOperation ) ;
500
509
} ) ) ) ;
501
510
}
502
511
503
- async function applyHotswappableChange ( sdk : SDK , ioSpan : IMessageSpan < any > , hotswapOperation : HotswapOperation ) : Promise < void > {
512
+ async function applyHotswapOperation ( sdk : SDK , ioSpan : IMessageSpan < any > , hotswapOperation : HotswapOperation ) : Promise < void > {
504
513
// note the type of service that was successfully hotswapped in the User-Agent
505
514
const customUserAgent = `cdk-hotswap/success-${ hotswapOperation . service } ` ;
506
515
sdk . appendCustomUserAgent ( customUserAgent ) ;
507
-
508
516
const resourceText = ( r : AffectedResource ) => r . description ?? `${ r . resourceType } '${ r . physicalName ?? r . logicalId } '` ;
509
517
510
- for ( const resource of hotswapOperation . change . resources ) {
511
- await ioSpan . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( format ( ` ${ ICON } %s` , chalk . bold ( resourceText ( resource ) ) ) ) ) ;
512
- }
518
+ await ioSpan . notify ( IO . CDK_TOOLKIT_I5402 . msg (
519
+ hotswapOperation . change . resources . map ( r => format ( ` ${ ICON } %s` , chalk . bold ( resourceText ( r ) ) ) ) . join ( '\n' ) ,
520
+ hotswapOperation . change ,
521
+ ) ) ;
513
522
514
523
// if the SDK call fails, an error will be thrown by the SDK
515
524
// and will prevent the green 'hotswapped!' text from being displayed
@@ -525,9 +534,10 @@ async function applyHotswappableChange(sdk: SDK, ioSpan: IMessageSpan<any>, hots
525
534
throw e ;
526
535
}
527
536
528
- for ( const resource of hotswapOperation . change . resources ) {
529
- await ioSpan . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( format ( `${ ICON } %s %s` , chalk . bold ( resourceText ( resource ) ) , chalk . green ( 'hotswapped!' ) ) ) ) ;
530
- }
537
+ await ioSpan . notify ( IO . CDK_TOOLKIT_I5403 . msg (
538
+ hotswapOperation . change . resources . map ( r => format ( ` ${ ICON } %s %s` , chalk . bold ( resourceText ( r ) ) , chalk . green ( 'hotswapped!' ) ) ) . join ( '\n' ) ,
539
+ hotswapOperation . change ,
540
+ ) ) ;
531
541
532
542
sdk . removeCustomUserAgent ( customUserAgent ) ;
533
543
}
@@ -550,12 +560,12 @@ function formatWaiterErrorResult(result: WaiterResult) {
550
560
return main ;
551
561
}
552
562
553
- async function logNonHotswappableChanges (
563
+ async function logRejectedChanges (
554
564
ioSpan : IMessageSpan < any > ,
555
- nonHotswappableChanges : RejectedChange [ ] ,
565
+ rejectedChanges : RejectedChange [ ] ,
556
566
hotswapMode : HotswapMode ,
557
567
) : Promise < void > {
558
- if ( nonHotswappableChanges . length === 0 ) {
568
+ if ( rejectedChanges . length === 0 ) {
559
569
return ;
560
570
}
561
571
/**
@@ -566,9 +576,9 @@ async function logNonHotswappableChanges(
566
576
* This logic prevents us from logging that change as non-hotswappable when we hotswap it.
567
577
*/
568
578
if ( hotswapMode === 'hotswap-only' ) {
569
- nonHotswappableChanges = nonHotswappableChanges . filter ( ( change ) => change . hotswapOnlyVisible === true ) ;
579
+ rejectedChanges = rejectedChanges . filter ( ( change ) => change . hotswapOnlyVisible === true ) ;
570
580
571
- if ( nonHotswappableChanges . length === 0 ) {
581
+ if ( rejectedChanges . length === 0 ) {
572
582
return ;
573
583
}
574
584
}
@@ -581,8 +591,8 @@ async function logNonHotswappableChanges(
581
591
messages . push ( format ( '%s %s' , chalk . red ( '⚠️' ) , chalk . red ( 'The following non-hotswappable changes were found:' ) ) ) ;
582
592
}
583
593
584
- for ( const rejection of nonHotswappableChanges ) {
585
- messages . push ( ' ' + nonHotswappableChangeMessage ( rejection . change ) ) ;
594
+ for ( const { change } of rejectedChanges ) {
595
+ messages . push ( ' ' + nonHotswappableChangeMessage ( change ) ) ;
586
596
}
587
597
messages . push ( '' ) ; // newline
588
598
0 commit comments