See: Description
| Class | Description |
|---|---|
| LambdaDestination |
Use a Lambda function as a bucket notification destination.
|
| SnsDestination |
Use an SNS topic as a bucket notification destination.
|
| SqsDestination |
Use an SQS queue as a bucket notification destination.
|
This module includes integration classes for using Topics, Queues or Lambdas as S3 Notification Destinations.
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));
Copyright © 2022. All rights reserved.