AWS Bus subscriptions
Subscribe bus events with AWS Lambda functions.
const bus = new sst.aws.Bus("Bus");
const publisher = new sst.aws.Function("Publisher", { handler: "./src/publisher.handler", url: true, link: [bus],});
bus.subscribe("Example", "./src/receiver.handler");import { bus } from "sst/aws/bus";import { z } from "zod";import { Resource } from "sst";import { MyEvent } from "./events";
export async function handler() { await bus.publish(Resource.Bus, MyEvent, { foo: "hello" });
return { statusCode: 200, };}import { bus } from "sst/aws/bus";import { MyEvent } from "./events";
export const handler = bus.subscriber([MyEvent], async (event) => { console.log({ event });});View the full example.