77 DescribeStacksCommand ,
88 GetTemplateCommand ,
99 ListChangeSetsCommand ,
10+ UpdateStackCommand ,
11+ waitUntilStackUpdateComplete ,
1012} from '@aws-sdk/client-cloudformation' ;
1113import { DescribeServicesCommand } from '@aws-sdk/client-ecs' ;
1214import {
@@ -633,14 +635,14 @@ integTest(
633635 const topicArn = response . TopicArn ! ;
634636
635637 try {
636- await fixture . cdkDeploy ( 'test-2 ' , {
638+ await fixture . cdkDeploy ( 'notification-arns ' , {
637639 options : [ '--notification-arns' , topicArn ] ,
638640 } ) ;
639641
640642 // verify that the stack we deployed has our notification ARN
641643 const describeResponse = await fixture . aws . cloudFormation . send (
642644 new DescribeStacksCommand ( {
643- StackName : fixture . fullStackName ( 'test-2 ' ) ,
645+ StackName : fixture . fullStackName ( 'notification-arns ' ) ,
644646 } ) ,
645647 ) ;
646648 expect ( describeResponse . Stacks ?. [ 0 ] . NotificationARNs ) . toEqual ( [ topicArn ] ) ;
@@ -661,15 +663,110 @@ integTest('deploy with notification ARN as prop', withDefaultFixture(async (fixt
661663 const topicArn = response . TopicArn ! ;
662664
663665 try {
664- await fixture . cdkDeploy ( 'notification-arn-prop' ) ;
666+ await fixture . cdkDeploy ( 'notification-arns' , {
667+ modEnv : {
668+ INTEG_NOTIFICATION_ARNS : topicArn ,
669+
670+ } ,
671+ } ) ;
665672
666673 // verify that the stack we deployed has our notification ARN
667674 const describeResponse = await fixture . aws . cloudFormation . send (
668675 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' ) ,
670752 } ) ,
671753 ) ;
672754 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 ( [ ] ) ;
673770 } finally {
674771 await fixture . aws . sns . send (
675772 new DeleteTopicCommand ( {
@@ -679,6 +776,43 @@ integTest('deploy with notification ARN as prop', withDefaultFixture(async (fixt
679776 }
680777} ) ) ;
681778
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+
682816// NOTE: this doesn't currently work with modern-style synthesis, as the bootstrap
683817// role by default will not have permission to iam:PassRole the created role.
684818integTest (
@@ -1064,6 +1198,46 @@ integTest(
10641198 } ) ,
10651199) ;
10661200
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+
10671241integTest ( 'cdk diff with large changeset and custom toolkit stack name and qualifier does not fail' , withoutBootstrap ( async ( fixture ) => {
10681242 // Bootstrapping with custom toolkit stack name and qualifier
10691243 const qualifier = 'abc1111' ;
0 commit comments