Bucket Notifications API for AWS S3
Project description
S3 Bucket Notifications Destinations
---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 aws_cdk.aws_sns as sns
bucket = s3.Bucket(self, "Bucket")
topic = sns.Topic(self, "Topic")
bucket.add_event_notification(s3.EventType.OBJECT_CREATED_PUT, s3n.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 aws_cdk.aws_sqs as sqs
bucket = s3.Bucket(self, "Bucket")
queue = sqs.Queue(self, "Queue")
bucket.add_event_notification(s3.EventType.OBJECT_CREATED_PUT, s3n.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 aws_cdk.aws_lambda as lambda_
bucket = s3.Bucket(self, "Bucket")
fn = lambda_.Function(self, "MyFunction",
runtime=lambda_.Runtime.NODEJS_14_X,
handler="index.handler",
code=lambda_.Code.from_asset(path.join(__dirname, "lambda-handler"))
)
bucket.add_event_notification(s3.EventType.OBJECT_CREATED, s3n.LambdaDestination(fn))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-cdk.aws-s3-notifications-1.204.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91f66b80ce08b9758c3ce2768bcab24db21a2df1ec9497138cebb9f33daf87f8 |
|
MD5 | ea78bc5cc807c2740d5745ee4f5f418b |
|
BLAKE2b-256 | afd0b6e1af61de836feabfd2a5205a7ecbbeca8c69e1345d60bd5d8905af20b6 |
Hashes for aws_cdk.aws_s3_notifications-1.204.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b2f9a88497fc2882fdf8e4bfb4262bb896f295b537afe93aa3bc03bdcf1c860 |
|
MD5 | e21d65a6dbb7477753aa882941129980 |
|
BLAKE2b-256 | 299a5498df16eb20a4463243dce0478593f4865ae38d086300aeba811777c0ae |