3 types
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:
require 'aws-cdk-lib'
bucket = AWSCDK::S3::Bucket.new(self, "Bucket")
topic = AWSCDK::SNS::Topic.new(self, "Topic")
bucket.add_event_notification(AWSCDK::S3::EventType::OBJECT_CREATED_PUT, AWSCDK::S3Notifications::SNSDestination.new(topic))
The following example shows how to send a notification to an SQS queue when an object is created in an S3 bucket:
require 'aws-cdk-lib'
bucket = AWSCDK::S3::Bucket.new(self, "Bucket")
queue = AWSCDK::SQS::Queue.new(self, "Queue")
bucket.add_event_notification(AWSCDK::S3::EventType::OBJECT_CREATED_PUT, AWSCDK::S3Notifications::SQSDestination.new(queue))
The following example shows how to send a notification to a Lambda function when an object is created in an S3 bucket:
require 'aws-cdk-lib'
bucket = AWSCDK::S3::Bucket.new(self, "Bucket")
fn = AWSCDK::Lambda::Function.new(self, "MyFunction", {
runtime: AWSCDK::Lambda::Runtime.NODEJS_LATEST,
handler: "index.handler",
code: AWSCDK::Lambda::Code.from_asset(path.join(__dirname, "lambda-handler")),
})
bucket.add_event_notification(AWSCDK::S3::EventType::OBJECT_CREATED, AWSCDK::S3Notifications::LambdaDestination.new(fn))