Skip to content

EventRule

Source: src/AWS/Notifications/EventRule.ts

An AWS User Notifications event rule — attaches an EventBridge source/event-type (optionally narrowed by an event pattern) to a NotificationConfiguration, across one or more regions.

source, eventType and the parent configuration are immutable (changing them replaces the rule); eventPattern and regions update in place. User Notifications materializes a managed EventBridge rule in every listed region.

Notify on S3 object creation

import * as Notifications from "alchemy/AWS/Notifications";
const config = yield* Notifications.NotificationConfiguration("Alerts");
const rule = yield* Notifications.EventRule("S3Created", {
notificationConfigurationArn: config.notificationConfigurationArn,
source: "aws.s3",
eventType: "Object Created",
regions: ["us-west-2"],
});

Restrict matches with an event pattern

const rule = yield* Notifications.EventRule("BucketRule", {
notificationConfigurationArn: config.notificationConfigurationArn,
source: "aws.s3",
eventType: "Object Created",
eventPattern: { detail: { bucket: { name: ["my-bucket"] } } },
regions: ["us-west-2", "us-east-2"],
});