s3, s3-notifications: allow configuring "Event Name" for Bucket event notifications
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
When I setup event notification for my S3 bucket.
I'd like to specify the "Event Name" for the Event notification.
For example, I use the following code which sets up a Bucket that sends object created events to an SNS topic:
```ts
import { App, CfnOutput, RemovalPolicy, Stack } from 'aws-cdk-lib';
import { Bucket, EventType } from 'aws-cdk-lib/aws-s3';
import { SnsDestination } from 'aws-cdk-lib/aws-s3-notifications';
import { Topic } from 'aws-cdk-lib/aws-sns';
const app = new App();
const stack = new Stack(app, "sns-add-object-created-notification");
const topic = new Topic(stack, "Topic", {
topicName: "my-topic",
displayName: "My Topic",
});
const bucket = new Bucket(stack, "Bucket", {
autoDeleteObjects: true,
removalPolicy: RemovalPolicy.DESTROY,
});
bucket.addEventNotification(
EventType.OBJECT_CREATED,
new SnsDestination(topic)
);
new CfnOutput(stack, "TopicName", {
value: topic.topicName,
});
new CfnOutput(stack, "BucketName", {
value: bucket.bucketName,
});
```
This is what I see in the console > Bucket properties:

Notice the randomly generated name. Also notice that if I were to set this up manually using the AWS console then I have the ability to specify the event name:

### Use Case
So that I can easily identify event notifications on S3 buckets.
### Proposed Solution
The event name is [not a supported CloudFormation configuration](https://repost.aws/questions/QUNPp_EcyCQ7CftyO36wcKoQ/s-3-notification-event-name-through-cloud-formation) yet ([feature-request here](https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/533)). However the way CDK currently sets up Bucket notifications is by deploying a lambda-backed custom resource. In this resource we might be able to pass a user defined name as the "Id" param for a Topic in the [`PutBucketNotificationConfiguration`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketNotificationConfiguration.html#API_PutBucketNotificationConfiguration_RequestSyntax) request.
### Other Information
Opened on behalf of customer. SIM P60886631
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.15.0 (build 151055e)
### Environment details (OS name and version, etc.)
Mac OS Monterey
Contributor guide
Research direction
Start at Bucket.addEventNotification in aws-s3 and the aws-s3-notifications custom resource described in the issue. Read the PutBucketNotificationConfiguration request syntax, focusing on the Topic Id, and determine how a user-defined event name can flow through the existing deployment path. Done means the notification name can be configured and is passed to S3 instead of being randomly generated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100