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): add EventBridge bucket notifications #18150

Merged
merged 6 commits into from
Jan 10, 2022
Merged

feat(s3): add EventBridge bucket notifications #18150

merged 6 commits into from
Jan 10, 2022

Conversation

yerzhan7
Copy link
Contributor

@yerzhan7 yerzhan7 commented Dec 23, 2021

Description

Adds EventBridge bucket notification configuration.

See https://aws.amazon.com/blogs/aws/new-use-amazon-s3-event-notifications-with-amazon-eventbridge/

Implementation

  • Added new Bucket property to enable this feature (eventBridgeEnabled: true)
  • Added EventBridge config to S3BucketNotifications Custom Resource
  • Added unit tests
  • Added integration test (currently fails, see below for more info)
  • Fixed dependent integration tests

Closes #18076

FAQ

  1. Why not simply expose EventBridge Cfn property via S3 BucketProps?

Currently CDK manages NotificationConfigurations via CustomResource. If we were to expose that way, then e.g. SNS configuration would override EventBridge config.

  1. Why not create new IBucketNotificationDestination class for EventBridge?

We can, but there is no need. Usually we create a subclass to IBucketNotificationDestination in order to adjust resource permissions, however in this case there is no need to adjust permissions: default EventBridge does not require any additional permissions unlike SQS/SNS/Lambda destinations. Additionally, enabling this feature via bucket props is much cleaner/simpler API than creating new dummy object of type IBucketNotificationDestination for customers.

However, if you still think that we need to create new IBucketNotificationDestination subclass for EventBridge for consistency, let me know and I will refactor.


BLOCKED ON LAMBDA RUNTIME SDK UPDATE TO BOTOCORE >= v1.23.16 (Integration test currently fails as current version (v1.21.55) does not contain EventBridge configuration)

Check latest version here: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Dec 23, 2021

@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Dec 23, 2021
@mergify
Copy link
Contributor

mergify bot commented Dec 23, 2021

Title does not follow the guidelines of Conventional Commits. Please adjust title before merge.

@yerzhan7 yerzhan7 changed the title (aws-s3): add EventBridge bucket notifications feat(s3): add EventBridge bucket notifications Dec 23, 2021
@mergify
Copy link
Contributor

mergify bot commented Jan 10, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 62e47e5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 912aeda into aws:master Jan 10, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 10, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@yerzhan7
Copy link
Contributor Author

@otaviomacedo , thanks for reviewing this PR.

However, as I mentioned in the description above, this feature is not working yet due to old AWS SDK version in Lambda.

Let's revert and wait for SDK update?

@orekav
Copy link
Contributor

orekav commented Jan 17, 2022

Is there an expected release date for the SDK update?

I want to use this for StepFunctions but CloudFormation does not like it
Received response status [FAILED] from custom resource. Message returned: Error: Parameter validation failed: Unknown parameter in NotificationConfiguration: "EventBridgeConfiguration", must be one of: TopicConfigurations, QueueConfigurations, LambdaFunctionConfigurations

@rankovr
Copy link

rankovr commented Jan 18, 2022

Hi team, I have the same problem as orekav:
I have upgraded my CDK to 1.139.0, but it is failing during the deploy with an error:
Unknown parameter in NotificationConfiguration: "EventBridgeConfiguration", must be one of: TopicConfigurations, QueueConfigurations, LambdaFunctionConfigurations.
my CDK version: 1.139.0, region: eu-central-1
https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_s3/README.html
bucket = s3.Bucket(self, "MyEventBridgeBucket",
event_bridge_enabled=True
)

mergify bot pushed a commit that referenced this pull request Jan 19, 2022
This reverts commit 912aeda.

## Why?

[PR#18150](#18150) was merged prematurely (See comments). To avoid customer confusion this PR reverts it.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
rix0rrr added a commit that referenced this pull request Jan 26, 2022
In #18150, a change was merged that blew up the size of the inline
Lambda beyond its limit of 4096 characters. This change was not
detected because the Lambda constructs being used there didn't use
the regular `aws-lambda` module, but escape hatches that bypass
the regular validation (released in 1.139.0, 2.8.0).

Because this effectively broke S3 notifications, it was rolled back
in #18507 (released in 1.140.0, not yet released in 2.x line).

In this PR, add validation to make sure an event like this doesn't
happen again. This will be relevant for #18614.
mergify bot pushed a commit that referenced this pull request Jan 26, 2022
In #18150, a change was merged that blew up the size of the inline
Lambda beyond its limit of 4096 characters. This change was not
detected because the Lambda constructs being used there didn't use
the regular `aws-lambda` module, but escape hatches that bypass
the regular validation (released in 1.139.0, 2.8.0).

Because this effectively broke S3 notifications, it was rolled back
in #18507 (released in 1.140.0, not yet released in 2.x line).

In this PR, add validation to make sure an event like this doesn't
happen again. This will be relevant for #18614.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
### **Description**

Adds EventBridge bucket notification configuration. 

See https://aws.amazon.com/blogs/aws/new-use-amazon-s3-event-notifications-with-amazon-eventbridge/


### **Implementation**

- Added new Bucket property to enable this feature (`eventBridgeEnabled: true`)
- Added EventBridge config to `S3BucketNotifications` Custom Resource
- Added unit tests
- Added integration test (currently fails, see below for more info) 
- Fixed dependent integration tests

Closes aws#18076

### **FAQ**

1. **Why not simply expose EventBridge Cfn property via S3 BucketProps?**

 Currently CDK manages `NotificationConfigurations `via CustomResource. If we were to expose that way, then e.g. SNS configuration would override EventBridge config.

2. **Why not create new `IBucketNotificationDestination` class for EventBridge?**

 We can, but there is no need. Usually we create a subclass to `IBucketNotificationDestination` in order to adjust resource permissions, however in this case there is no need to adjust permissions: [default EventBridge does not require any additional permissions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/ev-permissions.html) unlike SQS/SNS/Lambda destinations. Additionally, enabling this feature via bucket props is much cleaner/simpler API than creating new dummy object of type `IBucketNotificationDestination` for customers.
 
 However, if you still think that we need to create new `IBucketNotificationDestination` subclass for EventBridge for consistency, let me know and I will refactor.

----

**BLOCKED ON LAMBDA RUNTIME SDK UPDATE TO BOTOCORE >= v1.23.16 (Integration test currently fails as current version (v1.21.55) does not contain EventBridge configuration)**

Check latest version here: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
This reverts commit 912aeda.

## Why?

[PR#18150](aws#18150) was merged prematurely (See comments). To avoid customer confusion this PR reverts it.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
In aws#18150, a change was merged that blew up the size of the inline
Lambda beyond its limit of 4096 characters. This change was not
detected because the Lambda constructs being used there didn't use
the regular `aws-lambda` module, but escape hatches that bypass
the regular validation (released in 1.139.0, 2.8.0).

Because this effectively broke S3 notifications, it was rolled back
in aws#18507 (released in 1.140.0, not yet released in 2.x line).

In this PR, add validation to make sure an event like this doesn't
happen again. This will be relevant for aws#18614.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
mergify bot pushed a commit that referenced this pull request Apr 1, 2022
## Duplicate of #18150

## ~~Blocked on Lambda runtime SDK update to Botocore >= v1.23.16 (Integration test currently fails as current version (v1.21.55) does not contain EventBridge configuration)~~
## ~~Check latest version here: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html~~

### **Description**

Adds EventBridge bucket notification configuration. 

See https://aws.amazon.com/blogs/aws/new-use-amazon-s3-event-notifications-with-amazon-eventbridge/


### **Implementation**

- Added new Bucket property to enable this feature (`eventBridgeEnabled: true`)
- Added EventBridge config to `S3BucketNotifications` Custom Resource
- Added unit tests
- Added integration test (currently fails, see below for more info) 
- Fixed dependent integration tests

Closes #18076

### **FAQ**

1. **Why not simply expose EventBridge Cfn property via S3 BucketProps?**

 Currently CDK manages `NotificationConfigurations `via CustomResource. If we were to expose that way, then e.g. SNS configuration would override EventBridge config.

2. **Why not create new `IBucketNotificationDestination` class for EventBridge?**

 We can, but there is no need. Usually we create a subclass to `IBucketNotificationDestination` in order to adjust resource permissions, however in this case there is no need to adjust permissions: [default EventBridge does not require any additional permissions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/ev-permissions.html) unlike SQS/SNS/Lambda destinations. Additionally, enabling this feature via bucket props is much cleaner/simpler API than creating new dummy object of type `IBucketNotificationDestination` for customers.
 
 However, if you still think that we need to create new `IBucketNotificationDestination` subclass for EventBridge for consistency, let me know and I will refactor.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
StevePotter pushed a commit to StevePotter/aws-cdk that referenced this pull request Apr 27, 2022
## Duplicate of aws#18150

## ~~Blocked on Lambda runtime SDK update to Botocore >= v1.23.16 (Integration test currently fails as current version (v1.21.55) does not contain EventBridge configuration)~~
## ~~Check latest version here: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html~~

### **Description**

Adds EventBridge bucket notification configuration. 

See https://aws.amazon.com/blogs/aws/new-use-amazon-s3-event-notifications-with-amazon-eventbridge/


### **Implementation**

- Added new Bucket property to enable this feature (`eventBridgeEnabled: true`)
- Added EventBridge config to `S3BucketNotifications` Custom Resource
- Added unit tests
- Added integration test (currently fails, see below for more info) 
- Fixed dependent integration tests

Closes aws#18076

### **FAQ**

1. **Why not simply expose EventBridge Cfn property via S3 BucketProps?**

 Currently CDK manages `NotificationConfigurations `via CustomResource. If we were to expose that way, then e.g. SNS configuration would override EventBridge config.

2. **Why not create new `IBucketNotificationDestination` class for EventBridge?**

 We can, but there is no need. Usually we create a subclass to `IBucketNotificationDestination` in order to adjust resource permissions, however in this case there is no need to adjust permissions: [default EventBridge does not require any additional permissions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/ev-permissions.html) unlike SQS/SNS/Lambda destinations. Additionally, enabling this feature via bucket props is much cleaner/simpler API than creating new dummy object of type `IBucketNotificationDestination` for customers.
 
 However, if you still think that we need to create new `IBucketNotificationDestination` subclass for EventBridge for consistency, let me know and I will refactor.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-s3): adding prop to enable EventBridge in S3 BucketProps
5 participants