awss3notifications

package
v2.142.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

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 "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_LATEST(),
	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)

func NewSnsDestination_Override

func NewSnsDestination_Override(s SnsDestination, topic awssns.ITopic)

func NewSqsDestination_Override

func NewSqsDestination_Override(s SqsDestination, queue awssqs.IQueue)

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.
	Bind(_scope constructs.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/*"),
})

func NewLambdaDestination

func NewLambdaDestination(fn awslambda.IFunction) LambdaDestination

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.
	Bind(_scope constructs.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))

func NewSnsDestination

func NewSnsDestination(topic awssns.ITopic) SnsDestination

type SqsDestination

type SqsDestination interface {
	awss3.IBucketNotificationDestination
	// Allows using SQS queues as destinations for bucket notifications.
	//
	// Use `bucket.onEvent(event, queue)` to subscribe.
	Bind(_scope constructs.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"),
})

func NewSqsDestination

func NewSqsDestination(queue awssqs.IQueue) SqsDestination

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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