Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(s3): support replication and restore s3 notification event types #10552

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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