Skip to content

Stripe.AWS reference

Source: packages/stripe/src/AWS/ConsumeEventsEventBridge.ts Kind: Layer · Provides: Stripe.EventSource · Peer dependencies: @alchemy.run/aws

Receive Stripe events on an AWS Lambda Function through Amazon EventBridge, instead of a webhook. consumeEvents code is unchanged; provide this layer in place of Stripe.ConsumeEventsLive.

For each payload style it deploys a Stripe event destination targeting the Function’s account and region, the partner event bus that receives it, and a rule per event type that invokes the Function. Deliveries are authorized by IAM, so there is no signing secret and the Function needs no public URL. EventBridge retries failed invocations for up to 24 hours, and the bus can be archived and replayed. Partner events are billed by EventBridge (about $1 per million); a webhook costs nothing extra.

ConsumeEventsEventBridge: Receiving events on a Lambda

Section titled “ConsumeEventsEventBridge: Receiving events on a Lambda”
import * as AWS from "@alchemy.run/aws";
import * as Stripe from "@alchemy.run/stripe";
import { ConsumeEventsEventBridge } from "@alchemy.run/stripe/AWS";
import * as Effect from "effect/Effect";
export default class Billing extends AWS.Lambda.Function<Billing>()(
"Billing",
{ main: import.meta.url },
Effect.gen(function* () {
yield* Stripe.consumeEvents(
{ events: [Stripe.InvoicePaid, Stripe.MeterErrorReportTriggered] },
(event) => Effect.log(event.type),
);
return {};
}).pipe(Effect.provide(ConsumeEventsEventBridge)),
) {}