Skip to content

AWS.EventBridge reference

Source: src/AWS/EventBridge/ApiDestination.ts

An Amazon EventBridge API destination — an HTTPS endpoint configured as an event target, invoked with the authorization held by a Connection.

API destinations do not support tags, so ownership is tracked by the deterministic physical name.

Webhook API Destination

const destination = yield* AWS.EventBridge.ApiDestination("Webhook", {
connectionArn: connection.connectionArn,
invocationEndpoint: "https://hooks.example.com/events",
httpMethod: "POST",
});

Rate-Limited API Destination as a Rule Target

const destination = yield* AWS.EventBridge.ApiDestination("SlowApi", {
connectionArn: connection.connectionArn,
invocationEndpoint: "https://api.example.com/ingest",
httpMethod: "POST",
invocationRateLimitPerSecond: 10,
});
const rule = yield* AWS.EventBridge.Rule("ToApi", {
eventPattern: { source: ["my.app"] },
targets: [{
Id: "Api",
Arn: destination.apiDestinationArn,
RoleArn: role.roleArn,
}],
});

Source: src/AWS/EventBridge/Archive.ts

An Amazon EventBridge archive that retains events from an event bus so they can later be replayed (see the replay bindings: StartReplay, DescribeReplay, CancelReplay, ListReplays).

Archives do not support tags, so ownership is tracked by the deterministic physical name.

Archive All Events on a Bus

const bus = yield* AWS.EventBridge.EventBus("AppEvents", {});
const archive = yield* AWS.EventBridge.Archive("AppArchive", {
eventSourceArn: bus.eventBusArn,
retention: "30 days",
});

Archive a Filtered Subset of Events

const archive = yield* AWS.EventBridge.Archive("OrderArchive", {
eventSourceArn: bus.eventBusArn,
description: "Order events only",
eventPattern: { source: ["my.app"], "detail-type": ["OrderCreated"] },
retention: "90 days",
});

Source: src/AWS/EventBridge/BusSink.ts

A batching sink over EventBridge PutEvents (10 entries / 256 KiB per call). Per-entry failures with transient error codes (ThrottlingException, InternalFailure) are re-submitted on a bounded schedule; any other per-entry ErrorCode (e.g. MalformedDetail) is permanent — those entries are dropped and surfaced via a logged warning. Exhausting retries fails the sink with a typed BatchRetryExhaustedError carrying the stranded entries.

Omit the bus argument to publish to the account’s default event bus.

// init — bind the sink (provide AWS.EventBridge.BusSinkHttp on the Function)
const sink = yield* AWS.EventBridge.BusSink(bus);
return {
fetch: Effect.gen(function* () {
// runtime — publish a stream of raw PutEvents entries
const entries: AWS.EventBridge.BusSinkEntry[] = markers.map((marker) => ({
Source: "my.app",
DetailType: "MarkerSeen",
Detail: JSON.stringify({ marker }),
}));
yield* Stream.fromIterable(entries).pipe(Stream.run(sink));
return HttpServerResponse.json({ ok: true });
}),
};

Source: src/AWS/EventBridge/CancelReplay.ts

Cancels a running event replay (events:CancelReplay).

Bind this operation inside a function runtime to abort a replay started with StartReplay. Cancelling a replay that already completed fails with the typed IllegalStatusException. Provide the CancelReplayHttp layer on the Function to satisfy the binding.

// init — bind the operation (provide AWS.EventBridge.CancelReplayHttp on the Function)
const cancelReplay = yield* AWS.EventBridge.CancelReplay();
// runtime — abort the replay
yield* cancelReplay({ ReplayName: "backfill-2026-07-14" });

Source: src/AWS/EventBridge/Connection.ts

An Amazon EventBridge connection holding the authorization used to invoke an HTTP endpoint through an ApiDestination. EventBridge stores the secret half of the connection in Secrets Manager on your behalf.

Connections do not support tags, so ownership is tracked by the deterministic physical name.

API-Key Connection

import * as Redacted from "effect/Redacted";
const connection = yield* AWS.EventBridge.Connection("PartnerApi", {
authorizationType: "API_KEY",
authParameters: {
apiKeyAuthParameters: {
apiKeyName: "x-api-key",
apiKeyValue: Redacted.make(process.env.PARTNER_API_KEY!),
},
},
});

OAuth Client-Credentials Connection

const connection = yield* AWS.EventBridge.Connection("OAuthApi", {
authorizationType: "OAUTH_CLIENT_CREDENTIALS",
authParameters: {
oauthParameters: {
clientParameters: {
clientId: "my-client",
clientSecret: Redacted.make(process.env.OAUTH_SECRET!),
},
authorizationEndpoint: "https://auth.example.com/oauth/token",
httpMethod: "POST",
},
},
});

Source: src/AWS/EventBridge/DescribeEventBus.ts

Reads the configuration of an EventBridge event bus (events:DescribeEventBus).

Bind this operation to an EventBus inside a function runtime to get a callable that automatically injects the bus name. Provide the DescribeEventBusHttp layer on the Function to satisfy the binding.

// init — bind the bus (provide AWS.EventBridge.DescribeEventBusHttp on the Function)
const describeEventBus = yield* AWS.EventBridge.DescribeEventBus(bus);
// runtime — read the bus configuration
const info = yield* describeEventBus();
console.log(info.Arn, info.Policy);

Source: src/AWS/EventBridge/DescribeReplay.ts

Reads the progress and state of an event replay (events:DescribeReplay).

Bind this operation inside a function runtime to poll a replay started with StartReplay until it completes. Provide the DescribeReplayHttp layer on the Function to satisfy the binding.

// init — bind the operation (provide AWS.EventBridge.DescribeReplayHttp on the Function)
const describeReplay = yield* AWS.EventBridge.DescribeReplay();
// runtime — read the replay's state and progress
const replay = yield* describeReplay({ ReplayName: "backfill-2026-07-14" });
console.log(replay.State, replay.EventLastReplayedTime);

Source: src/AWS/EventBridge/DescribeRule.ts

Reads the configuration of an EventBridge rule (events:DescribeRule).

Bind this operation to a Rule inside a function runtime to get a callable that automatically injects the rule and bus names. Provide the DescribeRuleHttp layer on the Function to satisfy the binding.

// init — bind the rule (provide AWS.EventBridge.DescribeRuleHttp on the Function)
const describeRule = yield* AWS.EventBridge.DescribeRule(rule);
// runtime — read the rule's state and pattern
const info = yield* describeRule();
console.log(info.State, info.EventPattern);

Source: src/AWS/EventBridge/DisableRule.ts

Disables an EventBridge rule (events:DisableRule) so it stops matching events without deleting it.

Bind this operation to a Rule inside a function runtime to get a callable that pauses the rule — the runtime half of a feature toggle or kill switch. Provide the DisableRuleHttp layer on the Function to satisfy the binding.

// init — bind the rule (provide AWS.EventBridge.DisableRuleHttp on the Function)
const disableRule = yield* AWS.EventBridge.DisableRule(rule);
// runtime — stop event routing until re-enabled
yield* disableRule();

Source: src/AWS/EventBridge/EnableRule.ts

Enables an EventBridge rule (events:EnableRule) so it resumes matching events.

Bind this operation to a Rule inside a function runtime to get a callable that re-enables the rule — the runtime half of a feature toggle or kill switch. Provide the EnableRuleHttp layer on the Function to satisfy the binding.

// init — bind the rule (provide AWS.EventBridge.EnableRuleHttp on the Function)
const enableRule = yield* AWS.EventBridge.EnableRule(rule);
// runtime — turn event routing back on
yield* enableRule();

Source: src/AWS/EventBridge/EventBus.ts

An Amazon EventBridge event bus for receiving and routing events.

Custom Event Bus

const bus = yield* EventBus("MyAppEvents", {
description: "Custom event bus for my application",
});

Event Bus with Dead Letter Queue

const bus = yield* EventBus("ReliableBus", {
deadLetterConfig: {
Arn: yield* dlq.queueArn,
},
});

Event Bus with KMS Encryption

const bus = yield* EventBus("EncryptedBus", {
kmsKeyIdentifier: yield* key.keyArn(),
});

Source: src/AWS/EventBridge/EventSource.ts

Event source connecting an EventBridge EventBus to the hosting compute (Lambda function or ServerHost process). Matching events invoke the host with a stream of EventRecords.

Use it through the consumeBusEvents helper; the host-specific implementation layer (e.g. AWS.Lambda.EventSource) creates the rule, grants EventBridge invoke permission, and dispatches events at runtime.

// init — subscribe to matching events (provide AWS.Lambda.EventSource on the Function)
yield* AWS.EventBridge.consumeBusEvents(
bus,
{ source: ["my.app"] },
(events: Stream.Stream<AWS.EventBridge.EventRecord>) =>
events.pipe(
Stream.runForEach((event) =>
Effect.log(event["detail-type"], event.detail),
),
),
);

Source: src/AWS/EventBridge/ListEventBuses.ts

Lists the event buses in the account (events:ListEventBuses).

An account-level operation — bind it with no resource argument. Provide the ListEventBusesHttp layer on the Function to satisfy the binding.

// init — no resource argument (provide AWS.EventBridge.ListEventBusesHttp on the Function)
const listEventBuses = yield* AWS.EventBridge.ListEventBuses();
// runtime — list buses, optionally filtered by name prefix
const { EventBuses } = yield* listEventBuses({ NamePrefix: "my-app" });

Source: src/AWS/EventBridge/ListReplays.ts

Lists the event replays in the account (events:ListReplays).

Bind this operation inside a function runtime to enumerate replays, optionally filtered by name prefix, state, or source archive. Provide the ListReplaysHttp layer on the Function to satisfy the binding.

// init — bind the operation (provide AWS.EventBridge.ListReplaysHttp on the Function)
const listReplays = yield* AWS.EventBridge.ListReplays();
// runtime — enumerate replays currently running
const { Replays } = yield* listReplays({ State: "RUNNING" });

Source: src/AWS/EventBridge/ListRuleNamesByTarget.ts

Lists the EventBridge rules that route events to a given target ARN (events:ListRuleNamesByTarget).

Bind this operation inside a function runtime to introspect which rules feed a target (e.g. the function itself, or one of its queues). Provide the ListRuleNamesByTargetHttp layer on the Function to satisfy the binding.

// init — bind the operation (provide AWS.EventBridge.ListRuleNamesByTargetHttp on the Function)
const listRuleNamesByTarget = yield* AWS.EventBridge.ListRuleNamesByTarget();
// runtime — find every rule routing to the target
const { RuleNames } = yield* listRuleNamesByTarget({
TargetArn: "arn:aws:lambda:us-east-1:123456789012:function:my-fn",
});

Source: src/AWS/EventBridge/ListRules.ts

Lists the rules on an EventBridge event bus (events:ListRules).

Bind this operation to an EventBus inside a function runtime to get a callable scoped to that bus; omit the bus argument to list rules on the account’s default bus. Provide the ListRulesHttp layer on the Function to satisfy the binding.

// init — bind the bus (provide AWS.EventBridge.ListRulesHttp on the Function)
const listRules = yield* AWS.EventBridge.ListRules(bus);
// runtime — list rules, optionally filtered by name prefix
const { Rules } = yield* listRules({ NamePrefix: "orders-" });

Source: src/AWS/EventBridge/ListTargetsByRule.ts

Lists the targets attached to an EventBridge rule (events:ListTargetsByRule).

Bind this operation to a Rule inside a function runtime to get a callable that automatically injects the rule and bus names. Provide the ListTargetsByRuleHttp layer on the Function to satisfy the binding.

// init — bind the rule (provide AWS.EventBridge.ListTargetsByRuleHttp on the Function)
const listTargets = yield* AWS.EventBridge.ListTargetsByRule(rule);
// runtime — enumerate the rule's targets
const { Targets } = yield* listTargets();

Source: src/AWS/EventBridge/Permission.ts

An EventBridge event bus permission statement.

Permission manages a single PutPermission / RemovePermission lifecycle entry on an event bus so helper surfaces can safely grant publishers access without requiring callers to hand-write raw bus policies.

const permission = yield* Permission("PartnerPublish", {
eventBusName: bus.eventBusName,
principal: "123456789012",
});

Source: src/AWS/EventBridge/PutEvents.ts

Publishes events to an EventBridge event bus (events:PutEvents).

Bind this operation to an EventBus inside a function runtime to get a callable that automatically injects the bus name into every entry. Omit the bus argument to publish to the account’s default event bus. Provide the PutEventsHttp layer on the Function to satisfy the binding.

Publish an Event from a Handler

// init — bind the bus (provide AWS.EventBridge.PutEventsHttp on the Function)
const putEvents = yield* AWS.EventBridge.PutEvents(bus);
return {
fetch: Effect.gen(function* () {
// runtime — publish an event
const result = yield* putEvents({
Entries: [
{
Source: "my.app",
DetailType: "OrderCreated",
Detail: JSON.stringify({ orderId: "123" }),
},
],
});
return HttpServerResponse.json({
failedEntryCount: result.FailedEntryCount ?? 0,
});
}),
};

Publish to the Default Event Bus

// omit the bus argument to target the account's default bus
const putEvents = yield* AWS.EventBridge.PutEvents();
yield* putEvents({
Entries: [
{
Source: "my.app",
DetailType: "Heartbeat",
Detail: JSON.stringify({ at: new Date().toISOString() }),
},
],
});

Source: src/AWS/EventBridge/Rule.ts

An Amazon EventBridge rule that matches events and routes them to targets.

Event Pattern Rule

const rule = yield* Rule("S3Events", {
eventPattern: {
source: ["aws.s3"],
"detail-type": ["Object Created"],
},
targets: [{
Id: "MyTarget",
Arn: yield* queue.queueArn,
}],
});

Scheduled Rule

const rule = yield* Rule("EveryFiveMinutes", {
scheduleExpression: "rate(5 minutes)",
targets: [{
Id: "LambdaTarget",
Arn: yield* fn.functionArn(),
}],
});

Rule with Input Transformer

const rule = yield* Rule("TransformedEvents", {
eventPattern: {
source: ["aws.ec2"],
"detail-type": ["EC2 Instance State-change Notification"],
},
targets: [{
Id: "SqsTarget",
Arn: yield* queue.queueArn,
InputTransformer: {
InputPathsMap: {
instance: "$.detail.instance-id",
state: "$.detail.state",
},
InputTemplate: '{"instanceId": <instance>, "newState": <state>}',
},
}],
});

Rule with Dead Letter Queue

const rule = yield* Rule("ReliableEvents", {
eventPattern: { source: ["my.app"] },
targets: [{
Id: "Target",
Arn: yield* fn.functionArn(),
DeadLetterConfig: {
Arn: yield* dlq.queueArn,
},
RetryPolicy: {
MaximumRetryAttempts: 3,
MaximumEventAgeInSeconds: 3600,
},
}],
});

Rule with ECS Target

const rule = yield* Rule("EcsSchedule", {
scheduleExpression: "rate(1 hour)",
roleArn: yield* role.roleArn(),
targets: [{
Id: "EcsTask",
Arn: yield* cluster.clusterArn(),
RoleArn: yield* ecsRole.roleArn(),
EcsParameters: {
TaskDefinitionArn: yield* taskDef.taskDefinitionArn(),
TaskCount: 1,
LaunchType: "FARGATE",
NetworkConfiguration: {
awsvpcConfiguration: {
Subnets: ["subnet-abc123"],
AssignPublicIp: "ENABLED",
},
},
},
}],
});

Source: src/AWS/EventBridge/StartReplay.ts

Starts a replay of archived events (events:StartReplay).

Bind this operation to an Archive inside a function runtime to get a callable that replays a time window of archived events onto a destination event bus — the runtime half of disaster-recovery and backfill tooling. Provide the StartReplayHttp layer on the Function to satisfy the binding.

// init — bind the archive (provide AWS.EventBridge.StartReplayHttp on the Function)
const startReplay = yield* AWS.EventBridge.StartReplay(archive);
// runtime — replay yesterday's events back onto the archive's source bus
const replay = yield* startReplay({
ReplayName: "backfill-2026-07-14",
EventStartTime: new Date("2026-07-14T00:00:00Z"),
EventEndTime: new Date("2026-07-15T00:00:00Z"),
});

Source: src/AWS/EventBridge/TestEventPattern.ts

Tests whether an event matches an event pattern (events:TestEventPattern).

An account-level operation — bind it with no resource argument. Useful for validating patterns before creating a Rule. Provide the TestEventPatternHttp layer on the Function to satisfy the binding.

// init — no resource argument (provide AWS.EventBridge.TestEventPatternHttp on the Function)
const testEventPattern = yield* AWS.EventBridge.TestEventPattern();
// runtime — check whether the event would match
const { Result } = yield* testEventPattern({
EventPattern: JSON.stringify({ source: ["my.app"] }),
Event: JSON.stringify({
id: "1",
source: "my.app",
"detail-type": "OrderCreated",
account: "123456789012",
region: "us-east-1",
time: new Date().toISOString(),
detail: {},
}),
});

Source: src/AWS/EventBridge/ToEcsTask.ts

Routes matching events from an EventBridge bus to an ECS task run.

Creates a Rule targeting the ECS cluster plus an IAM role that lets EventBridge call ecs:RunTask with the given task definition (Fargate launch type). Usually reached through the events(...) builder rather than called directly.

yield* AWS.EventBridge.events(bus, { source: ["my.app"] }).toEcsTask(cluster, {
task: {
taskDefinitionArn: yield* taskDefinition.taskDefinitionArn,
taskRoleArn: yield* taskRole.roleArn,
executionRoleArn: yield* executionRole.roleArn,
},
subnets: subnetIds,
assignPublicIp: true,
});

Source: src/AWS/EventBridge/ToLambda.ts

Routes matching events from an EventBridge bus to a Lambda function.

Creates a Rule targeting the function and a Lambda permission allowing events.amazonaws.com to invoke it. Usually reached through the events(...) builder rather than called directly.

Route Matching Events to a Lambda Function

yield* AWS.EventBridge.events(bus, { source: ["my.app"] }).toLambda(fn);

Transform the Event Payload Before Invoking

yield* AWS.EventBridge.events(bus, { source: ["my.app"] }).toLambda(fn, {
InputTransformer: {
InputPathsMap: { orderId: "$.detail.orderId" },
InputTemplate: '{"orderId": <orderId>}',
},
});

Source: src/AWS/EventBridge/ToQueue.ts

Routes matching events from an EventBridge bus to an SQS queue.

Creates a Rule targeting the queue and binds a queue policy that allows events.amazonaws.com to send messages from that rule. Usually reached through the events(...) builder rather than called directly.

yield* AWS.EventBridge.events(bus, { source: ["my.app"] }).toQueue(queue);