Skip to content
GitHub Discord

Bucket topic notifications

Create an S3 bucket and subscribe to its events with an SNS topic.

sst.config.ts
const topic = new sst.aws.SnsTopic("MyTopic");
topic.subscribe("MySubscriber", "subscriber.handler");
const bucket = new sst.aws.Bucket("MyBucket");
bucket.notify({
notifications: [
{
name: "MySubscriber",
topic,
events: ["s3:ObjectCreated:*"],
},
],
});
subscriber.ts
export const handler = async (event) => {
console.log(event);
return "ok";
};

View the full example.