Skip to content

Commit

Permalink
feat(s3): support replication and restore s3 notification event types (
Browse files Browse the repository at this point in the history
…#10552)

Adding support for [additional S3 notification event types](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types), including 's3:ObjectRestore:Completed' recently raised by @mauricioharley as a feature request.

Closes #10498

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rrhodes authored Sep 29, 2020
1 parent a3c41ae commit ee0db39
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
51 changes: 49 additions & 2 deletions packages/@aws-cdk/aws-s3/lib/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ export class Bucket extends BucketBase {
}

/**
* Subscribes a destination to receive notificatins when an object is
* Subscribes a destination to receive notifications when an object is
* created in the bucket. This is identical to calling
* `onEvent(EventType.ObjectCreated)`.
*
Expand All @@ -1334,7 +1334,7 @@ export class Bucket extends BucketBase {
}

/**
* Subscribes a destination to receive notificatins when an object is
* Subscribes a destination to receive notifications when an object is
* removed from the bucket. This is identical to calling
* `onEvent(EventType.ObjectRemoved)`.
*
Expand Down Expand Up @@ -1782,12 +1782,59 @@ export enum EventType {
*/
OBJECT_REMOVED_DELETE_MARKER_CREATED = 's3:ObjectRemoved:DeleteMarkerCreated',

/**
* Using restore object event types you can receive notifications for
* initiation and completion when restoring objects from the S3 Glacier
* storage class.
*
* You use s3:ObjectRestore:Post to request notification of object restoration
* initiation.
*/
OBJECT_RESTORE_POST = 's3:ObjectRestore:Post',

/**
* Using restore object event types you can receive notifications for
* initiation and completion when restoring objects from the S3 Glacier
* storage class.
*
* You use s3:ObjectRestore:Completed to request notification of
* restoration completion.
*/
OBJECT_RESTORE_COMPLETED = 's3:ObjectRestore:Completed',

/**
* You can use this event type to request Amazon S3 to send a notification
* message when Amazon S3 detects that an object of the RRS storage class is
* lost.
*/
REDUCED_REDUNDANCY_LOST_OBJECT = 's3:ReducedRedundancyLostObject',

/**
* You receive this notification event when an object that was eligible for
* replication using Amazon S3 Replication Time Control failed to replicate.
*/
REPLICATION_OPERATION_FAILED_REPLICATION = 's3:Replication:OperationFailedReplication',

/**
* You receive this notification event when an object that was eligible for
* replication using Amazon S3 Replication Time Control exceeded the 15-minute
* threshold for replication.
*/
REPLICATION_OPERATION_MISSED_THRESHOLD = 's3:Replication:OperationMissedThreshold',

/**
* You receive this notification event for an object that was eligible for
* replication using the Amazon S3 Replication Time Control feature replicated
* after the 15-minute threshold.
*/
REPLICATION_OPERATION_REPLICATED_AFTER_THRESHOLD = 's3:Replication:OperationReplicatedAfterThreshold',

/**
* You receive this notification event for an object that was eligible for
* replication using Amazon S3 Replication Time Control but is no longer tracked
* by replication metrics.
*/
REPLICATION_OPERATION_NOT_TRACKED = 's3:Replication:OperationNotTracked',
}

export interface NotificationKeyFilter {
Expand Down
15 changes: 13 additions & 2 deletions packages/@aws-cdk/aws-s3/test/test.notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Test } from 'nodeunit';
import * as s3 from '../lib';

export = {
'when notification are added, a custom resource is provisioned + a lambda handler for it'(test: Test) {
'when notification is added a custom s3 bucket notification resource is provisioned'(test: Test) {
const stack = new cdk.Stack();

const bucket = new s3.Bucket(stack, 'MyBucket');
Expand All @@ -17,7 +17,18 @@ export = {
});

expect(stack).to(haveResource('AWS::S3::Bucket'));
expect(stack).to(haveResource('Custom::S3BucketNotifications'));
expect(stack).to(haveResource('Custom::S3BucketNotifications', {
NotificationConfiguration: {
TopicConfigurations: [
{
Events: [
's3:ObjectCreated:*',
],
TopicArn: 'ARN',
},
],
},
}));

test.done();
},
Expand Down

0 comments on commit ee0db39

Please sign in to comment.