-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(aws-s3): Bucket Notifications (#201)
Adds support for S3 bucket notifications. The `bucket.onEvent` method will add a notification destination for a bucket. The s3.INotificationDestination interface is used to allow SNS, SQS and Lambda to implement notification destinations. This interface inverts the control and allows the destination to prepare to receive notifications. For example, it can modify it's policy appropriately. Since CloudFormation bucket notification support require two-phase deployments (due to the fact PutBucketNotification will fail if the destination policy has not been updated, and CloudFormation cannot create the policy until the bucket is created). The reason this is a limitation in CloudFormation is that they could not model the 1:1 relationship between the bucket and the notifications using the current semantics of CloudFormation. In the CDK, we can model this relationship by encapsulating the notifications custom resource behind a bucket. This means that users don't interact with this resource directly, but rather just subscribe to notifications on a bucket, and the resource (and accompanying handler) will be created as needed.
- Loading branch information
Elad Ben-Israel
authored
Aug 13, 2018
1 parent
a283a39
commit 8cd07e6
Showing
11 changed files
with
1,199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export * from './bucket'; | ||
export * from './bucket-policy'; | ||
export * from './rule'; | ||
export * from './notification-dest'; | ||
|
||
// AWS::S3 CloudFormation Resources: | ||
export * from './s3.generated'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { Bucket } from './bucket'; | ||
|
||
/** | ||
* Implemented by constructs that can be used as bucket notification destinations. | ||
*/ | ||
export interface IBucketNotificationDestination { | ||
/** | ||
* Registers this resource to receive notifications for the specified bucket. | ||
* @param bucket The bucket. Use the `path` of the bucket as a unique ID. | ||
*/ | ||
asBucketNotificationDestination(bucket: Bucket): BucketNotificationDestinationProps; | ||
} | ||
|
||
/** | ||
* Represents the properties of a notification destination. | ||
*/ | ||
export interface BucketNotificationDestinationProps { | ||
/** | ||
* The notification type. | ||
*/ | ||
readonly type: BucketNotificationDestinationType; | ||
|
||
/** | ||
* The ARN of the destination (i.e. Lambda, SNS, SQS). | ||
*/ | ||
readonly arn: cdk.Arn; | ||
} | ||
|
||
/** | ||
* Supported types of notification destinations. | ||
*/ | ||
export enum BucketNotificationDestinationType { | ||
Lambda, | ||
Queue, | ||
Topic | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './notifications-resource'; |
Oops, something went wrong.