This package has been deprecated

Author message:

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

@aws-cdk/aws-s3-notifications
TypeScript icon, indicating that this package has built-in type declarations

1.204.0 • Public • Published

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 * as sns from '@aws-cdk/aws-sns';

const bucket = new s3.Bucket(this, 'Bucket');
const topic = new sns.Topic(this, 'Topic');

bucket.addEventNotification(s3.EventType.OBJECT_CREATED_PUT, new 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 * as sqs from '@aws-cdk/aws-sqs';

const bucket = new s3.Bucket(this, 'Bucket');
const queue = new sqs.Queue(this, 'Queue');

bucket.addEventNotification(s3.EventType.OBJECT_CREATED_PUT, new 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 * as lambda from '@aws-cdk/aws-lambda';

const bucket = new s3.Bucket(this, 'Bucket');
const fn = new lambda.Function(this, 'MyFunction', {
  runtime: lambda.Runtime.NODEJS_14_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});

bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(fn));

Readme

Keywords

Package Sidebar

Install

npm i @aws-cdk/aws-s3-notifications

Weekly Downloads

9,719

Version

1.204.0

License

Apache-2.0

Unpacked Size

89.9 kB

Total Files

17

Last publish

Collaborators

  • amzn-oss
  • aws-cdk-team