Skip navigation links

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

S3 Bucket Notifications Destinations

See: Description

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

S3 Bucket Notifications Destinations

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:

 // Example automatically generated from non-compiling source. May contain errors.
 import software.amazon.awscdk.core.*;
 
 
 Bucket bucket = new Bucket(stack, "Bucket");
 Topic topic = new Topic(stack, "Topic");
 
 bucket.addEventNotification(EventType.OBJECT_CREATED_PUT, new SnsDestination(topic));
 

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

 // Example automatically generated from non-compiling source. May contain errors.
 import software.amazon.awscdk.core.*;
 
 
 Bucket bucket = new Bucket(stack, "Bucket");
 Function fn = new Function(this, "MyFunction", Map.of(
         "runtime", Runtime.getNODEJS_12_X(),
         "handler", "index.handler",
         "code", Code.fromAsset(path.join(__dirname, "lambda-handler"))));
 
 bucket.addEventNotification(EventType.OBJECT_CREATED, new LambdaDestination(fn));
 
Skip navigation links

Copyright © 2022. All rights reserved.