@@ -30,8 +30,7 @@ import {
30
30
import type { ChangeSetDeploymentMethod , DeploymentMethod } from './deployment-method' ;
31
31
import type { DeployStackResult , SuccessfulDeployStackResult } from './deployment-result' ;
32
32
import { tryHotswapDeployment } from './hotswap-deployments' ;
33
- import type { IoHelper } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/private' ;
34
- import { debug , info , warn } from '../../cli/messages' ;
33
+ import { IO , type IoHelper } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/private' ;
35
34
import { ToolkitError } from '../../toolkit/error' ;
36
35
import { formatErrorMessage } from '../../util' ;
37
36
import type { SDK , SdkProvider , ICloudFormationClient } from '../aws-auth' ;
@@ -214,7 +213,7 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe
214
213
let cloudFormationStack = await CloudFormationStack . lookup ( cfn , deployName ) ;
215
214
216
215
if ( cloudFormationStack . stackStatus . isCreationFailure ) {
217
- await ioHelper . notify ( debug (
216
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg (
218
217
`Found existing stack ${ deployName } that had previously failed creation. Deleting it before attempting to re-create it.` ,
219
218
) ) ;
220
219
await cfn . deleteStack ( { StackName : deployName } ) ;
@@ -253,11 +252,11 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe
253
252
const hotswapPropertyOverrides = options . hotswapPropertyOverrides ?? new HotswapPropertyOverrides ( ) ;
254
253
255
254
if ( await canSkipDeploy ( options , cloudFormationStack , stackParams . hasChanges ( cloudFormationStack . parameters ) , ioHelper ) ) {
256
- await ioHelper . notify ( debug ( `${ deployName } : skipping deployment (use --force to override)` ) ) ;
255
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : skipping deployment (use --force to override)` ) ) ;
257
256
// if we can skip deployment and we are performing a hotswap, let the user know
258
257
// that no hotswap deployment happened
259
258
if ( hotswapMode !== HotswapMode . FULL_DEPLOYMENT ) {
260
- await ioHelper . notify ( info (
259
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_INFO . msg (
261
260
format (
262
261
`\n ${ ICON } %s\n` ,
263
262
chalk . bold ( 'hotswap deployment skipped - no changes were detected (use --force to override)' ) ,
@@ -271,7 +270,7 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe
271
270
stackArn : cloudFormationStack . stackId ,
272
271
} ;
273
272
} else {
274
- await ioHelper . notify ( debug ( `${ deployName } : deploying...` ) ) ;
273
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : deploying...` ) ) ;
275
274
}
276
275
277
276
const bodyParameter = await makeBodyParameter (
@@ -285,7 +284,7 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe
285
284
try {
286
285
bootstrapStackName = ( await options . envResources . lookupToolkit ( ) ) . stackName ;
287
286
} catch ( e ) {
288
- await ioHelper . notify ( debug ( `Could not determine the bootstrap stack name: ${ e } ` ) ) ;
287
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `Could not determine the bootstrap stack name: ${ e } ` ) ) ;
289
288
}
290
289
await publishAssets ( legacyAssets . toManifest ( stackArtifact . assembly . directory ) , options . sdkProvider , stackEnv , {
291
290
parallel : options . assetParallelism ,
@@ -301,27 +300,30 @@ export async function deployStack(options: DeployStackOptions, ioHelper: IoHelpe
301
300
stackParams . values ,
302
301
cloudFormationStack ,
303
302
stackArtifact ,
304
- hotswapMode , hotswapPropertyOverrides ,
303
+ hotswapMode ,
304
+ hotswapPropertyOverrides ,
305
305
) ;
306
+
306
307
if ( hotswapDeploymentResult ) {
307
308
return hotswapDeploymentResult ;
308
309
}
309
- await ioHelper . notify ( info ( format (
310
+
311
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( format (
310
312
'Could not perform a hotswap deployment, as the stack %s contains non-Asset changes' ,
311
313
stackArtifact . displayName ,
312
314
) ) ) ;
313
315
} catch ( e ) {
314
316
if ( ! ( e instanceof CfnEvaluationException ) ) {
315
317
throw e ;
316
318
}
317
- await ioHelper . notify ( info ( format (
319
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( format (
318
320
'Could not perform a hotswap deployment, because the CloudFormation template could not be resolved: %s' ,
319
321
formatErrorMessage ( e ) ,
320
322
) ) ) ;
321
323
}
322
324
323
325
if ( hotswapMode === HotswapMode . FALL_BACK ) {
324
- await ioHelper . notify ( info ( 'Falling back to doing a full deployment' ) ) ;
326
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( 'Falling back to doing a full deployment' ) ) ;
325
327
options . sdk . appendCustomUserAgent ( 'cdk-hotswap/fallback' ) ;
326
328
} else {
327
329
return {
@@ -404,17 +406,17 @@ class FullCloudFormationDeployment {
404
406
await this . updateTerminationProtection ( ) ;
405
407
406
408
if ( changeSetHasNoChanges ( changeSetDescription ) ) {
407
- await this . ioHelper . notify ( debug ( format ( 'No changes are to be performed on %s.' , this . stackName ) ) ) ;
409
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( format ( 'No changes are to be performed on %s.' , this . stackName ) ) ) ;
408
410
if ( execute ) {
409
- await this . ioHelper . notify ( debug ( format ( 'Deleting empty change set %s' , changeSetDescription . ChangeSetId ) ) ) ;
411
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( format ( 'Deleting empty change set %s' , changeSetDescription . ChangeSetId ) ) ) ;
410
412
await this . cfn . deleteChangeSet ( {
411
413
StackName : this . stackName ,
412
414
ChangeSetName : changeSetName ,
413
415
} ) ;
414
416
}
415
417
416
418
if ( this . options . force ) {
417
- await this . ioHelper . notify ( warn (
419
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_WARN . msg (
418
420
[
419
421
'You used the --force flag, but CloudFormation reported that the deployment would not make any changes.' ,
420
422
'According to CloudFormation, all resources are already up-to-date with the state in your CDK app.' ,
@@ -434,7 +436,7 @@ class FullCloudFormationDeployment {
434
436
}
435
437
436
438
if ( ! execute ) {
437
- await this . ioHelper . notify ( info ( format (
439
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( format (
438
440
'Changeset %s created and waiting in review for manual execution (--no-execute)' ,
439
441
changeSetDescription . ChangeSetId ,
440
442
) ) ) ;
@@ -466,8 +468,8 @@ class FullCloudFormationDeployment {
466
468
private async createChangeSet ( changeSetName : string , willExecute : boolean , importExistingResources : boolean ) {
467
469
await this . cleanupOldChangeset ( changeSetName ) ;
468
470
469
- await this . ioHelper . notify ( debug ( `Attempting to create ChangeSet with name ${ changeSetName } to ${ this . verb } stack ${ this . stackName } ` ) ) ;
470
- await this . ioHelper . notify ( info ( format ( '%s: creating CloudFormation changeset...' , chalk . bold ( this . stackName ) ) ) ) ;
471
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `Attempting to create ChangeSet with name ${ changeSetName } to ${ this . verb } stack ${ this . stackName } ` ) ) ;
472
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( format ( '%s: creating CloudFormation changeset...' , chalk . bold ( this . stackName ) ) ) ) ;
471
473
const changeSet = await this . cfn . createChangeSet ( {
472
474
StackName : this . stackName ,
473
475
ChangeSetName : changeSetName ,
@@ -479,15 +481,15 @@ class FullCloudFormationDeployment {
479
481
...this . commonPrepareOptions ( ) ,
480
482
} ) ;
481
483
482
- await this . ioHelper . notify ( debug ( format ( 'Initiated creation of changeset: %s; waiting for it to finish creating...' , changeSet . Id ) ) ) ;
484
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( format ( 'Initiated creation of changeset: %s; waiting for it to finish creating...' , changeSet . Id ) ) ) ;
483
485
// Fetching all pages if we'll execute, so we can have the correct change count when monitoring.
484
486
return waitForChangeSet ( this . cfn , this . ioHelper , this . stackName , changeSetName , {
485
487
fetchAll : willExecute ,
486
488
} ) ;
487
489
}
488
490
489
491
private async executeChangeSet ( changeSet : DescribeChangeSetCommandOutput ) : Promise < SuccessfulDeployStackResult > {
490
- await this . ioHelper . notify ( debug ( format ( 'Initiating execution of changeset %s on stack %s' , changeSet . ChangeSetId , this . stackName ) ) ) ;
492
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( format ( 'Initiating execution of changeset %s on stack %s' , changeSet . ChangeSetId , this . stackName ) ) ) ;
491
493
492
494
await this . cfn . executeChangeSet ( {
493
495
StackName : this . stackName ,
@@ -496,7 +498,7 @@ class FullCloudFormationDeployment {
496
498
...this . commonExecuteOptions ( ) ,
497
499
} ) ;
498
500
499
- await this . ioHelper . notify ( debug (
501
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg (
500
502
format (
501
503
'Execution of changeset %s on stack %s has started; waiting for the update to complete...' ,
502
504
changeSet . ChangeSetId ,
@@ -513,7 +515,7 @@ class FullCloudFormationDeployment {
513
515
if ( this . cloudFormationStack . exists ) {
514
516
// Delete any existing change sets generated by CDK since change set names must be unique.
515
517
// The delete request is successful as long as the stack exists (even if the change set does not exist).
516
- await this . ioHelper . notify ( debug ( `Removing existing change set with name ${ changeSetName } if it exists` ) ) ;
518
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `Removing existing change set with name ${ changeSetName } if it exists` ) ) ;
517
519
await this . cfn . deleteChangeSet ( {
518
520
StackName : this . stackName ,
519
521
ChangeSetName : changeSetName ,
@@ -525,7 +527,7 @@ class FullCloudFormationDeployment {
525
527
// Update termination protection only if it has changed.
526
528
const terminationProtection = this . stackArtifact . terminationProtection ?? false ;
527
529
if ( ! ! this . cloudFormationStack . terminationProtection !== terminationProtection ) {
528
- await this . ioHelper . notify ( debug (
530
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg (
529
531
format (
530
532
'Updating termination protection from %s to %s for stack %s' ,
531
533
this . cloudFormationStack . terminationProtection ,
@@ -537,12 +539,12 @@ class FullCloudFormationDeployment {
537
539
StackName : this . stackName ,
538
540
EnableTerminationProtection : terminationProtection ,
539
541
} ) ;
540
- await this . ioHelper . notify ( debug ( format ( 'Termination protection updated to %s for stack %s' , terminationProtection , this . stackName ) ) ) ;
542
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( format ( 'Termination protection updated to %s for stack %s' , terminationProtection , this . stackName ) ) ) ;
541
543
}
542
544
}
543
545
544
546
private async directDeployment ( ) : Promise < SuccessfulDeployStackResult > {
545
- await this . ioHelper . notify ( info ( format ( '%s: %s stack...' , chalk . bold ( this . stackName ) , this . update ? 'updating' : 'creating' ) ) ) ;
547
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_INFO . msg ( format ( '%s: %s stack...' , chalk . bold ( this . stackName ) , this . update ? 'updating' : 'creating' ) ) ) ;
546
548
547
549
const startTime = new Date ( ) ;
548
550
@@ -558,7 +560,7 @@ class FullCloudFormationDeployment {
558
560
} ) ;
559
561
} catch ( err : any ) {
560
562
if ( err . message === 'No updates are to be performed.' ) {
561
- await this . ioHelper . notify ( debug ( format ( 'No updates are to be performed for stack %s' , this . stackName ) ) ) ;
563
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( format ( 'No updates are to be performed for stack %s' , this . stackName ) ) ) ;
562
564
return {
563
565
type : 'did-deploy-stack' ,
564
566
noOp : true ,
@@ -611,7 +613,7 @@ class FullCloudFormationDeployment {
611
613
} finally {
612
614
await monitor . stop ( ) ;
613
615
}
614
- debug ( format ( 'Stack %s has completed updating' , this . stackName ) ) ;
616
+ await this . ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( format ( 'Stack %s has completed updating' , this . stackName ) ) ) ;
615
617
return {
616
618
type : 'did-deploy-stack' ,
617
619
noOp : false ,
@@ -709,11 +711,11 @@ async function canSkipDeploy(
709
711
ioHelper : IoHelper ,
710
712
) : Promise < boolean > {
711
713
const deployName = deployStackOptions . deployName || deployStackOptions . stack . stackName ;
712
- await ioHelper . notify ( debug ( `${ deployName } : checking if we can skip deploy` ) ) ;
714
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : checking if we can skip deploy` ) ) ;
713
715
714
716
// Forced deploy
715
717
if ( deployStackOptions . force ) {
716
- await ioHelper . notify ( debug ( `${ deployName } : forced deployment` ) ) ;
718
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : forced deployment` ) ) ;
717
719
return false ;
718
720
}
719
721
@@ -722,53 +724,53 @@ async function canSkipDeploy(
722
724
deployStackOptions . deploymentMethod ?. method === 'change-set' &&
723
725
deployStackOptions . deploymentMethod . execute === false
724
726
) {
725
- await ioHelper . notify ( debug ( `${ deployName } : --no-execute, always creating change set` ) ) ;
727
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : --no-execute, always creating change set` ) ) ;
726
728
return false ;
727
729
}
728
730
729
731
// No existing stack
730
732
if ( ! cloudFormationStack . exists ) {
731
- await ioHelper . notify ( debug ( `${ deployName } : no existing stack` ) ) ;
733
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : no existing stack` ) ) ;
732
734
return false ;
733
735
}
734
736
735
737
// Template has changed (assets taken into account here)
736
738
if ( JSON . stringify ( deployStackOptions . stack . template ) !== JSON . stringify ( await cloudFormationStack . template ( ) ) ) {
737
- await ioHelper . notify ( debug ( `${ deployName } : template has changed` ) ) ;
739
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : template has changed` ) ) ;
738
740
return false ;
739
741
}
740
742
741
743
// Tags have changed
742
744
if ( ! compareTags ( cloudFormationStack . tags , deployStackOptions . tags ?? [ ] ) ) {
743
- await ioHelper . notify ( debug ( `${ deployName } : tags have changed` ) ) ;
745
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : tags have changed` ) ) ;
744
746
return false ;
745
747
}
746
748
747
749
// Notification arns have changed
748
750
if ( ! arrayEquals ( cloudFormationStack . notificationArns , deployStackOptions . notificationArns ?? [ ] ) ) {
749
- await ioHelper . notify ( debug ( `${ deployName } : notification arns have changed` ) ) ;
751
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : notification arns have changed` ) ) ;
750
752
return false ;
751
753
}
752
754
753
755
// Termination protection has been updated
754
756
if ( ! ! deployStackOptions . stack . terminationProtection !== ! ! cloudFormationStack . terminationProtection ) {
755
- await ioHelper . notify ( debug ( `${ deployName } : termination protection has been updated` ) ) ;
757
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : termination protection has been updated` ) ) ;
756
758
return false ;
757
759
}
758
760
759
761
// Parameters have changed
760
762
if ( parameterChanges ) {
761
763
if ( parameterChanges === 'ssm' ) {
762
- await ioHelper . notify ( debug ( `${ deployName } : some parameters come from SSM so we have to assume they may have changed` ) ) ;
764
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : some parameters come from SSM so we have to assume they may have changed` ) ) ;
763
765
} else {
764
- await ioHelper . notify ( debug ( `${ deployName } : parameters have changed` ) ) ;
766
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : parameters have changed` ) ) ;
765
767
}
766
768
return false ;
767
769
}
768
770
769
771
// Existing stack is in a failed state
770
772
if ( cloudFormationStack . stackStatus . isFailure ) {
771
- await ioHelper . notify ( debug ( `${ deployName } : stack is in a failure state` ) ) ;
773
+ await ioHelper . notify ( IO . DEFAULT_TOOLKIT_DEBUG . msg ( `${ deployName } : stack is in a failure state` ) ) ;
772
774
return false ;
773
775
}
774
776
0 commit comments