From 4de6d567ddae97c517e9b866a1540eca025772d1 Mon Sep 17 00:00:00 2001 From: corymhall <43035978+corymhall@users.noreply.github.com> Date: Wed, 6 Apr 2022 18:27:31 +0000 Subject: [PATCH] chore(s3-notifications): fix broken integration tests related to #16811, there is sometimes an issue when multiple operations are performed on the same bucket. To get around this in the integration test I created an additional bucket for the import test. --- .../test/integ.notifications.expected.json | 13 +++++++++---- .../test/integ.notifications.ts | 8 ++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/@aws-cdk/aws-s3-notifications/test/integ.notifications.expected.json b/packages/@aws-cdk/aws-s3-notifications/test/integ.notifications.expected.json index ffab9e0aacf65..0e0162c3837ea 100644 --- a/packages/@aws-cdk/aws-s3-notifications/test/integ.notifications.expected.json +++ b/packages/@aws-cdk/aws-s3-notifications/test/integ.notifications.expected.json @@ -159,7 +159,7 @@ }, ":s3:::", { - "Ref": "Bucket25524B414" + "Ref": "Bucket3CFB7F7D7" } ] ] @@ -312,7 +312,12 @@ "Topic3DEAE47A7" ] }, - "Bucket3NotificationsAFEFF359": { + "Bucket3CFB7F7D7": { + "Type": "AWS::S3::Bucket", + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "Bucket3ImportedNotificationsB1625F39": { "Type": "Custom::S3BucketNotifications", "Properties": { "ServiceToken": { @@ -322,7 +327,7 @@ ] }, "BucketName": { - "Ref": "Bucket25524B414" + "Ref": "Bucket3CFB7F7D7" }, "NotificationConfiguration": { "TopicConfigurations": [ @@ -344,4 +349,4 @@ ] } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3-notifications/test/integ.notifications.ts b/packages/@aws-cdk/aws-s3-notifications/test/integ.notifications.ts index 5e1f11d42a6ef..b4fd7c3ac604f 100644 --- a/packages/@aws-cdk/aws-s3-notifications/test/integ.notifications.ts +++ b/packages/@aws-cdk/aws-s3-notifications/test/integ.notifications.ts @@ -21,7 +21,11 @@ const bucket2 = new s3.Bucket(stack, 'Bucket2', { }); bucket2.addObjectRemovedNotification(new s3n.SnsDestination(topic3), { prefix: 'foo' }, { suffix: 'foo/bar' }); -const bucket3 = s3.Bucket.fromBucketName(stack, 'Bucket3', bucket2.bucketName); -bucket3.addEventNotification(s3.EventType.OBJECT_CREATED_COPY, new s3n.SnsDestination(topic3)); +const bucket3 = new s3.Bucket(stack, 'Bucket3', { + removalPolicy: cdk.RemovalPolicy.DESTROY, +}); + +const importedBucket3 = s3.Bucket.fromBucketName(stack, 'Bucket3Imported', bucket3.bucketName); +importedBucket3.addEventNotification(s3.EventType.OBJECT_CREATED_COPY, new s3n.SnsDestination(topic3)); app.synth();