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 setups up a Bucket that sends object created events to an SNS topic:
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.
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 setups up a Bucket that sends object created events to an SNS topic:
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 yet (feature-request here). 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
request.Other Information
Opened on behalf of customer. SIM P60886631
Acknowledgements
CDK version used
2.15.0 (build 151055e)
Environment details (OS name and version, etc.)
Mac OS Monterey