Skip to content
v2.275.0

SnsDestination Class ​

Use an SNS topic as a bucket notification destination.

Example ​

ts
const bucket = new s3.Bucket(this, 'MyBucket');
const topic = new sns.Topic(this, 'MyTopic');
bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.SnsDestination(topic));
python
bucket = s3.Bucket(self, "MyBucket")
topic = sns.Topic(self, "MyTopic")
bucket.add_event_notification(s3.EventType.OBJECT_CREATED, s3n.SnsDestination(topic))
java
Bucket bucket = new Bucket(this, "MyBucket");
Topic topic = new Topic(this, "MyTopic");
bucket.addEventNotification(EventType.OBJECT_CREATED, new SnsDestination(topic));
csharp
// Install: dotnet add package Amazon.CDK.Lib
var bucket = new Bucket(this, "MyBucket");
var topic = new Topic(this, "MyTopic");
bucket.AddEventNotification(EventType.OBJECT_CREATED, new SnsDestination(topic));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
bucket := s3.NewBucket(this, jsii.String("MyBucket"))
topic := sns.NewTopic(this, jsii.String("MyTopic"))
bucket.AddEventNotification(s3.EventType_OBJECT_CREATED, s3n.NewSnsDestination(topic))

Initializer ​

ts
new SnsDestination(topic: ITopic)
python
SnsDestination(topic: ITopic)
java
new SnsDestination(ITopic topic)
csharp
new SnsDestination(ITopic topic)
go
NewSnsDestination(Topic ITopic)

Methods ​

bind(scope: Construct, bucket: IBucketRef): BucketNotificationDestinationConfigdef bind(self, scope: Construct, bucket: IBucketRef) -> BucketNotificationDestinationConfigpublic BucketNotificationDestinationConfig bind(Construct scope, IBucketRef bucket)public BucketNotificationDestinationConfig Bind(Construct scope, IBucketRef bucket)func Bind(Scope Construct, Bucket IBucketRef) BucketNotificationDestinationConfig#
Registers this resource to receive notifications for the specified bucket.

This method will only be called once for each destination/bucket pair and the result will be cached, so there is no need to implement idempotency in each destination.