awss3notifications

package
v1.168.0-devpreview Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

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:

import sns "github.com/aws/aws-cdk-go/awscdk"


bucket := s3.NewBucket(this, jsii.String("Bucket"))
topic := sns.NewTopic(this, jsii.String("Topic"))

bucket.addEventNotification(s3.eventType_OBJECT_CREATED_PUT, s3n.NewSnsDestination(topic))

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

import sqs "github.com/aws/aws-cdk-go/awscdk"


bucket := s3.NewBucket(this, jsii.String("Bucket"))
queue := sqs.NewQueue(this, jsii.String("Queue"))

bucket.addEventNotification(s3.eventType_OBJECT_CREATED_PUT, s3n.NewSqsDestination(queue))

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

import lambda "github.com/aws/aws-cdk-go/awscdk"


bucket := s3.NewBucket(this, jsii.String("Bucket"))
fn := lambda.NewFunction(this, jsii.String("MyFunction"), &functionProps{
	runtime: lambda.runtime_NODEJS_12_X(),
	handler: jsii.String("index.handler"),
	code: lambda.code.fromAsset(path.join(__dirname, jsii.String("lambda-handler"))),
})

bucket.addEventNotification(s3.eventType_OBJECT_CREATED, s3n.NewLambdaDestination(fn))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLambdaDestination_Override

func NewLambdaDestination_Override(l LambdaDestination, fn awslambda.IFunction)

Experimental.

func NewSnsDestination_Override

func NewSnsDestination_Override(s SnsDestination, topic awssns.ITopic)

Experimental.

func NewSqsDestination_Override

func NewSqsDestination_Override(s SqsDestination, queue awssqs.IQueue)

Experimental.

Types

type LambdaDestination

type LambdaDestination interface {
	awss3.IBucketNotificationDestination
	// Registers this resource to receive notifications for the specified bucket.
	//
	// This method will only be called once for each destination/bucket
	// pair and the result will be cached, so there is no need to implement
	// idempotency in each destination.
	// Experimental.
	Bind(_scope awscdk.Construct, bucket awss3.IBucket) *awss3.BucketNotificationDestinationConfig
}

Use a Lambda function as a bucket notification destination.

Example:

var myLambda function

bucket := s3.bucket.fromBucketAttributes(this, jsii.String("ImportedBucket"), &bucketAttributes{
	bucketArn: jsii.String("arn:aws:s3:::my-bucket"),
})

// now you can just call methods on the bucket
bucket.addEventNotification(s3.eventType_OBJECT_CREATED, s3n.NewLambdaDestination(myLambda), &notificationKeyFilter{
	prefix: jsii.String("home/myusername/*"),
})

Experimental.

func NewLambdaDestination

func NewLambdaDestination(fn awslambda.IFunction) LambdaDestination

Experimental.

type SnsDestination

type SnsDestination interface {
	awss3.IBucketNotificationDestination
	// Registers this resource to receive notifications for the specified bucket.
	//
	// This method will only be called once for each destination/bucket
	// pair and the result will be cached, so there is no need to implement
	// idempotency in each destination.
	// Experimental.
	Bind(_scope awscdk.Construct, bucket awss3.IBucket) *awss3.BucketNotificationDestinationConfig
}

Use an SNS topic as a bucket notification destination.

Example:

bucket := s3.NewBucket(this, jsii.String("MyBucket"))
topic := sns.NewTopic(this, jsii.String("MyTopic"))
bucket.addEventNotification(s3.eventType_OBJECT_CREATED, s3n.NewSnsDestination(topic))

Experimental.

func NewSnsDestination

func NewSnsDestination(topic awssns.ITopic) SnsDestination

Experimental.

type SqsDestination

type SqsDestination interface {
	awss3.IBucketNotificationDestination
	// Allows using SQS queues as destinations for bucket notifications.
	//
	// Use `bucket.onEvent(event, queue)` to subscribe.
	// Experimental.
	Bind(_scope awscdk.Construct, bucket awss3.IBucket) *awss3.BucketNotificationDestinationConfig
}

Use an SQS queue as a bucket notification destination.

Example:

var myQueue queue

bucket := s3.NewBucket(this, jsii.String("MyBucket"))
bucket.addEventNotification(s3.eventType_OBJECT_REMOVED,
s3n.NewSqsDestination(myQueue), &notificationKeyFilter{
	prefix: jsii.String("foo/"),
	suffix: jsii.String(".jpg"),
})

Experimental.

func NewSqsDestination

func NewSqsDestination(queue awssqs.IQueue) SqsDestination

Experimental.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL