Skip to content

Commit

Permalink
chore(s3-notifications): fix broken integration tests (#19793)
Browse files Browse the repository at this point in the history
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.


----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
corymhall authored Apr 6, 2022
1 parent 73e8b66 commit ad16386
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
},
":s3:::",
{
"Ref": "Bucket25524B414"
"Ref": "Bucket3CFB7F7D7"
}
]
]
Expand Down Expand Up @@ -312,7 +312,12 @@
"Topic3DEAE47A7"
]
},
"Bucket3NotificationsAFEFF359": {
"Bucket3CFB7F7D7": {
"Type": "AWS::S3::Bucket",
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"Bucket3ImportedNotificationsB1625F39": {
"Type": "Custom::S3BucketNotifications",
"Properties": {
"ServiceToken": {
Expand All @@ -322,7 +327,7 @@
]
},
"BucketName": {
"Ref": "Bucket25524B414"
"Ref": "Bucket3CFB7F7D7"
},
"NotificationConfiguration": {
"TopicConfigurations": [
Expand All @@ -344,4 +349,4 @@
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

0 comments on commit ad16386

Please sign in to comment.