BucketNotification
The BucketNotification component is internally used by the Bucket component to
add bucket notifications to AWS S3 Bucket.
You’ll find this component returned by the notify method of the Bucket component.
Constructor
new BucketNotification(name, args, opts?)Parameters
-
namestring -
argsArgs -
opts?ComponentResourceOptions
Properties
nodes
Type Object
The underlying resources this component creates.
nodes.notification
Type BucketNotification
The notification resource that’s created.
nodes.functions
Type Output<Function[]>
The functions that will be notified.
Args
bucket
bucket.arn
Type Input<string>
The ARN of the bucket.
bucket.name
Type Input<string>
The name of the bucket.
eventBridge?
Type Input<boolean>
Default false
Enable EventBridge notifications for this bucket. This publishes every S3 event of
the bucket to the account’s default EventBridge bus. It doesn’t send them anywhere
by itself: add rules with Bucket.subscribeEventBridge,
or your own rules on the default bus, to react to them.
S3 keeps a single notification configuration for each bucket. To use EventBridge
together with the queue, topic and function notifications below, set it in the
same notify call. Calling notify again would replace what was set before, so
it isn’t allowed.
Set it to false to turn EventBridge notifications off.
{ eventBridge: true, notifications: [ { name: "MySubscriber", queue: myQueue } ]}notifications?
Type Input<Input<Object>[]>
A list of subscribers that’ll be notified when events happen in the bucket. Leave
it out if the bucket only uses eventBridge.
notifications[].events?
Type Input<Input<“s3:ObjectCreated:*” | “s3:ObjectCreated:Put” | “s3:ObjectCreated:Post” | “s3:ObjectCreated:Copy” | “s3:ObjectCreated:CompleteMultipartUpload” | “s3:ObjectRemoved:*” | “s3:ObjectRemoved:Delete” | “s3:ObjectRemoved:DeleteMarkerCreated” | “s3:ObjectRestore:*” | “s3:ObjectRestore:Post” | “s3:ObjectRestore:Completed” | “s3:ObjectRestore:Delete” | “s3:ReducedRedundancyLostObject” | “s3:Replication:*” | “s3:Replication:OperationFailedReplication” | “s3:Replication:OperationMissedThreshold” | “s3:Replication:OperationReplicatedAfterThreshold” | “s3:Replication:OperationNotTracked” | “s3:LifecycleExpiration:*” | “s3:LifecycleExpiration:Delete” | “s3:LifecycleExpiration:DeleteMarkerCreated” | “s3:LifecycleTransition” | “s3:IntelligentTiering” | “s3:ObjectTagging:*” | “s3:ObjectTagging:Put” | “s3:ObjectTagging:Delete” | “s3:ObjectAcl:Put”>[]>
Default All S3 events
A list of S3 event types that’ll trigger a notification.
{ events: ["s3:ObjectCreated:*", "s3:ObjectRemoved:*"]}notifications[].filterPrefix?
Type Input<string>
An S3 object key prefix that will trigger a notification.
To be notified for all the objects in the images/ folder.
{ filterPrefix: "images/"}notifications[].filterSuffix?
Type Input<string>
An S3 object key suffix that will trigger the notification.
To be notified for all the objects with the .jpg suffix.
{ filterSuffix: ".jpg"}notifications[].function?
Type Input<string | FunctionArgs | “arn:aws:lambda:${string}”>
The function that’ll be notified.
{ name: "MySubscriber", function: "src/subscriber.handler"}Customize the subscriber function. The link ensures the subscriber can access the
bucket through the SDK.
{ name: "MySubscriber", function: { handler: "src/subscriber.handler", timeout: "60 seconds", link: [bucket] }}Or pass in the ARN of an existing Lambda function.
{ name: "MySubscriber", function: "arn:aws:lambda:us-east-1:123456789012:function:my-function"}notifications[].name
Type Input<string>
The name of the subscriber.
notifications[].queue?
Type Input<string | Queue>
The Queue that’ll be notified.
For example, let’s say you have a queue.
const myQueue = new sst.aws.Queue("MyQueue");You can subscribe to this bucket with it.
{ name: "MySubscriber", queue: myQueue}Or pass in the ARN of an existing SQS queue.
{ name: "MySubscriber", queue: "arn:aws:sqs:us-east-1:123456789012:my-queue"}notifications[].topic?
Type Input<string | SnsTopic>
The SNS topic that’ll be notified.
For example, let’s say you have a topic.
const myTopic = new sst.aws.SnsTopic("MyTopic");You can subscribe to this bucket with it.
{ name: "MySubscriber", topic: myTopic}Or pass in the ARN of an existing SNS topic.
{ name: "MySubscriber", topic: "arn:aws:sns:us-east-1:123456789012:my-topic"}transform?
Type Object
Transform how this notification creates its underlying resources.
transform.notification?
Type BucketNotificationArgs | (args: BucketNotificationArgs, opts: ComponentResourceOptions, name: string) => void
Transform the S3 Bucket Notification resource.