Package software.amazon.awscdk.services.s3.notifications


@Stability(Stable) @Deprecated package software.amazon.awscdk.services.s3.notifications
Deprecated.

S3 Bucket Notifications Destinations

---

End-of-Support

AWS CDK v1 has reached End-of-Support on 2023-06-01. This package is no longer being updated, and users should migrate to AWS CDK v2.

For more information on how to migrate, see the Migrating to AWS CDK v2 guide.


This module includes integration classes for using Topics, Queues or Lambdas as S3 Notification Destinations.

Examples

The following example shows how to send a notification to an SNS topic when an object is created in an S3 bucket:

 import software.amazon.awscdk.services.sns.*;
 
 
 Bucket bucket = new Bucket(this, "Bucket");
 Topic topic = new Topic(this, "Topic");
 
 bucket.addEventNotification(EventType.OBJECT_CREATED_PUT, new SnsDestination(topic));
 

The following example shows how to send a notification to an SQS queue when an object is created in an S3 bucket:

 import software.amazon.awscdk.services.sqs.*;
 
 
 Bucket bucket = new Bucket(this, "Bucket");
 Queue queue = new Queue(this, "Queue");
 
 bucket.addEventNotification(EventType.OBJECT_CREATED_PUT, new SqsDestination(queue));
 

The following example shows how to send a notification to a Lambda function when an object is created in an S3 bucket:

 import software.amazon.awscdk.services.lambda.*;
 
 
 Bucket bucket = new Bucket(this, "Bucket");
 Function fn = Function.Builder.create(this, "MyFunction")
         .runtime(Runtime.NODEJS_14_X)
         .handler("index.handler")
         .code(Code.fromAsset(join(__dirname, "lambda-handler")))
         .build();
 
 bucket.addEventNotification(EventType.OBJECT_CREATED, new LambdaDestination(fn));
 
Deprecated: AWS CDK v1 has reached End-of-Support on 2023-06-01. This package is no longer being updated, and users should migrate to AWS CDK v2. For more information on how to migrate, see https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html