Skip to content

notifications

Source: src/AWS/S3/BucketNotifications.ts

Subscribe to S3 bucket event notifications.

Returns an object with a .subscribe(process) method that receives a Stream<BucketNotification> for processing events.

Process all object creation events

import * as S3 from "alchemy/AWS/S3";
yield* S3.notifications(bucket, {
events: ["s3:ObjectCreated:*"],
}).subscribe((stream) =>
stream.pipe(
Stream.runForEach((event) =>
Effect.log(`New object: ${event.key} (${event.size} bytes)`),
),
),
);

Process all events (no filter)

yield* S3.notifications(bucket).subscribe((stream) =>
stream.pipe(
Stream.runForEach((event) =>
Effect.log(`${event.type}: ${event.key}`),
),
),
);