7
7
DescribeStacksCommand ,
8
8
GetTemplateCommand ,
9
9
ListChangeSetsCommand ,
10
+ UpdateStackCommand ,
11
+ waitUntilStackUpdateComplete ,
10
12
} from '@aws-sdk/client-cloudformation' ;
11
13
import { DescribeServicesCommand } from '@aws-sdk/client-ecs' ;
12
14
import {
@@ -633,14 +635,14 @@ integTest(
633
635
const topicArn = response . TopicArn ! ;
634
636
635
637
try {
636
- await fixture . cdkDeploy ( 'test-2 ' , {
638
+ await fixture . cdkDeploy ( 'notification-arns ' , {
637
639
options : [ '--notification-arns' , topicArn ] ,
638
640
} ) ;
639
641
640
642
// verify that the stack we deployed has our notification ARN
641
643
const describeResponse = await fixture . aws . cloudFormation . send (
642
644
new DescribeStacksCommand ( {
643
- StackName : fixture . fullStackName ( 'test-2 ' ) ,
645
+ StackName : fixture . fullStackName ( 'notification-arns ' ) ,
644
646
} ) ,
645
647
) ;
646
648
expect ( describeResponse . Stacks ?. [ 0 ] . NotificationARNs ) . toEqual ( [ topicArn ] ) ;
@@ -661,15 +663,110 @@ integTest('deploy with notification ARN as prop', withDefaultFixture(async (fixt
661
663
const topicArn = response . TopicArn ! ;
662
664
663
665
try {
664
- await fixture . cdkDeploy ( 'notification-arn-prop' ) ;
666
+ await fixture . cdkDeploy ( 'notification-arns' , {
667
+ modEnv : {
668
+ INTEG_NOTIFICATION_ARNS : topicArn ,
669
+
670
+ } ,
671
+ } ) ;
665
672
666
673
// verify that the stack we deployed has our notification ARN
667
674
const describeResponse = await fixture . aws . cloudFormation . send (
668
675
new DescribeStacksCommand ( {
669
- StackName : fixture . fullStackName ( 'notification-arn-prop' ) ,
676
+ StackName : fixture . fullStackName ( 'notification-arns' ) ,
677
+ } ) ,
678
+ ) ;
679
+ expect ( describeResponse . Stacks ?. [ 0 ] . NotificationARNs ) . toEqual ( [ topicArn ] ) ;
680
+ } finally {
681
+ await fixture . aws . sns . send (
682
+ new DeleteTopicCommand ( {
683
+ TopicArn : topicArn ,
684
+ } ) ,
685
+ ) ;
686
+ }
687
+ } ) ) ;
688
+
689
+ // https://github.com/aws/aws-cdk/issues/32153
690
+ integTest ( 'deploy preserves existing notification arns when not specified' , withDefaultFixture ( async ( fixture ) => {
691
+ const topicName = `${ fixture . stackNamePrefix } -topic` ;
692
+
693
+ const response = await fixture . aws . sns . send ( new CreateTopicCommand ( { Name : topicName } ) ) ;
694
+ const topicArn = response . TopicArn ! ;
695
+
696
+ try {
697
+ await fixture . cdkDeploy ( 'notification-arns' ) ;
698
+
699
+ // add notification arns externally to cdk
700
+ await fixture . aws . cloudFormation . send (
701
+ new UpdateStackCommand ( {
702
+ StackName : fixture . fullStackName ( 'notification-arns' ) ,
703
+ UsePreviousTemplate : true ,
704
+ NotificationARNs : [ topicArn ] ,
705
+ } ) ,
706
+ ) ;
707
+
708
+ await waitUntilStackUpdateComplete (
709
+ {
710
+ client : fixture . aws . cloudFormation ,
711
+ maxWaitTime : 600 ,
712
+ } ,
713
+ { StackName : fixture . fullStackName ( 'notification-arns' ) } ,
714
+ ) ;
715
+
716
+ // deploy again
717
+ await fixture . cdkDeploy ( 'notification-arns' ) ;
718
+
719
+ // make sure the notification arn is preserved
720
+ const describeResponse = await fixture . aws . cloudFormation . send (
721
+ new DescribeStacksCommand ( {
722
+ StackName : fixture . fullStackName ( 'notification-arns' ) ,
723
+ } ) ,
724
+ ) ;
725
+ expect ( describeResponse . Stacks ?. [ 0 ] . NotificationARNs ) . toEqual ( [ topicArn ] ) ;
726
+ } finally {
727
+ await fixture . aws . sns . send (
728
+ new DeleteTopicCommand ( {
729
+ TopicArn : topicArn ,
730
+ } ) ,
731
+ ) ;
732
+ }
733
+ } ) ) ;
734
+
735
+ integTest ( 'deploy deletes ALL notification arns when empty array is passed' , withDefaultFixture ( async ( fixture ) => {
736
+ const topicName = `${ fixture . stackNamePrefix } -topic` ;
737
+
738
+ const response = await fixture . aws . sns . send ( new CreateTopicCommand ( { Name : topicName } ) ) ;
739
+ const topicArn = response . TopicArn ! ;
740
+
741
+ try {
742
+ await fixture . cdkDeploy ( 'notification-arns' , {
743
+ modEnv : {
744
+ INTEG_NOTIFICATION_ARNS : topicArn ,
745
+ } ,
746
+ } ) ;
747
+
748
+ // make sure the arn was added
749
+ let describeResponse = await fixture . aws . cloudFormation . send (
750
+ new DescribeStacksCommand ( {
751
+ StackName : fixture . fullStackName ( 'notification-arns' ) ,
670
752
} ) ,
671
753
) ;
672
754
expect ( describeResponse . Stacks ?. [ 0 ] . NotificationARNs ) . toEqual ( [ topicArn ] ) ;
755
+
756
+ // deploy again with empty array
757
+ await fixture . cdkDeploy ( 'notification-arns' , {
758
+ modEnv : {
759
+ INTEG_NOTIFICATION_ARNS : '' ,
760
+ } ,
761
+ } ) ;
762
+
763
+ // make sure the arn was deleted
764
+ describeResponse = await fixture . aws . cloudFormation . send (
765
+ new DescribeStacksCommand ( {
766
+ StackName : fixture . fullStackName ( 'notification-arns' ) ,
767
+ } ) ,
768
+ ) ;
769
+ expect ( describeResponse . Stacks ?. [ 0 ] . NotificationARNs ) . toEqual ( [ ] ) ;
673
770
} finally {
674
771
await fixture . aws . sns . send (
675
772
new DeleteTopicCommand ( {
@@ -679,6 +776,43 @@ integTest('deploy with notification ARN as prop', withDefaultFixture(async (fixt
679
776
}
680
777
} ) ) ;
681
778
779
+ integTest ( 'deploy with notification ARN as prop and flag' , withDefaultFixture ( async ( fixture ) => {
780
+ const topic1Name = `${ fixture . stackNamePrefix } -topic1` ;
781
+ const topic2Name = `${ fixture . stackNamePrefix } -topic1` ;
782
+
783
+ const topic1Arn = ( await fixture . aws . sns . send ( new CreateTopicCommand ( { Name : topic1Name } ) ) ) . TopicArn ! ;
784
+ const topic2Arn = ( await fixture . aws . sns . send ( new CreateTopicCommand ( { Name : topic2Name } ) ) ) . TopicArn ! ;
785
+
786
+ try {
787
+ await fixture . cdkDeploy ( 'notification-arns' , {
788
+ modEnv : {
789
+ INTEG_NOTIFICATION_ARNS : topic1Arn ,
790
+
791
+ } ,
792
+ options : [ '--notification-arns' , topic2Arn ] ,
793
+ } ) ;
794
+
795
+ // verify that the stack we deployed has our notification ARN
796
+ const describeResponse = await fixture . aws . cloudFormation . send (
797
+ new DescribeStacksCommand ( {
798
+ StackName : fixture . fullStackName ( 'notification-arns' ) ,
799
+ } ) ,
800
+ ) ;
801
+ expect ( describeResponse . Stacks ?. [ 0 ] . NotificationARNs ) . toEqual ( [ topic1Arn , topic2Arn ] ) ;
802
+ } finally {
803
+ await fixture . aws . sns . send (
804
+ new DeleteTopicCommand ( {
805
+ TopicArn : topic1Arn ,
806
+ } ) ,
807
+ ) ;
808
+ await fixture . aws . sns . send (
809
+ new DeleteTopicCommand ( {
810
+ TopicArn : topic2Arn ,
811
+ } ) ,
812
+ ) ;
813
+ }
814
+ } ) ) ;
815
+
682
816
// NOTE: this doesn't currently work with modern-style synthesis, as the bootstrap
683
817
// role by default will not have permission to iam:PassRole the created role.
684
818
integTest (
@@ -1064,6 +1198,46 @@ integTest(
1064
1198
} ) ,
1065
1199
) ;
1066
1200
1201
+ integTest (
1202
+ 'cdk diff doesnt show resource metadata changes' ,
1203
+ withDefaultFixture ( async ( fixture ) => {
1204
+
1205
+ // GIVEN - small initial stack with default resource metadata
1206
+ await fixture . cdkDeploy ( 'metadata' ) ;
1207
+
1208
+ // WHEN - changing resource metadata value
1209
+ const diff = await fixture . cdk ( [ 'diff' , fixture . fullStackName ( 'metadata' ) ] , {
1210
+ verbose : true ,
1211
+ modEnv : {
1212
+ INTEG_METADATA_VALUE : 'custom' ,
1213
+ } ,
1214
+ } ) ;
1215
+
1216
+ // Assert there are no changes
1217
+ expect ( diff ) . toContain ( 'There were no differences' ) ;
1218
+ } ) ,
1219
+ ) ;
1220
+
1221
+ integTest (
1222
+ 'cdk diff shows resource metadata changes with --no-change-set' ,
1223
+ withDefaultFixture ( async ( fixture ) => {
1224
+
1225
+ // GIVEN - small initial stack with default resource metadata
1226
+ await fixture . cdkDeploy ( 'metadata' ) ;
1227
+
1228
+ // WHEN - changing resource metadata value
1229
+ const diff = await fixture . cdk ( [ 'diff --no-change-set' , fixture . fullStackName ( 'metadata' ) ] , {
1230
+ verbose : true ,
1231
+ modEnv : {
1232
+ INTEG_METADATA_VALUE : 'custom' ,
1233
+ } ,
1234
+ } ) ;
1235
+
1236
+ // Assert there are changes
1237
+ expect ( diff ) . not . toContain ( 'There were no differences' ) ;
1238
+ } ) ,
1239
+ ) ;
1240
+
1067
1241
integTest ( 'cdk diff with large changeset and custom toolkit stack name and qualifier does not fail' , withoutBootstrap ( async ( fixture ) => {
1068
1242
// Bootstrapping with custom toolkit stack name and qualifier
1069
1243
const qualifier = 'abc1111' ;
0 commit comments