import type { IAlarmAction } from "aws-cdk-lib/aws-cloudwatch"; import { type IConstruct } from "constructs"; import { type AlarmRuleScope } from "./policy-matcher.js"; export type { AlarmMatchContext, AlarmMatcher } from "./policy-matcher.js"; /** A set of actions, one array per alarm state. All arrays are optional. */ export interface AlarmActionSet { alarmActions?: IAlarmAction[]; okActions?: IAlarmAction[]; insufficientDataActions?: IAlarmAction[]; } /** A rule: a matcher (or matchers) plus an action set, with optional scoping flags. */ export interface AlarmActionRule extends AlarmActionSet, AlarmRuleScope { /** When this rule matches, suppress `defaults` for the alarm. */ replaceDefaults?: boolean; } /** Configuration for {@link alarmActionsPolicy}. */ export interface AlarmActionsPolicyConfig { /** Actions applied to every matched alarm unless a matching rule sets `replaceDefaults: true`. */ defaults?: AlarmActionSet; /** Ordered list of overrides. All matching rules contribute (append semantics). */ rules?: AlarmActionRule[]; /** Skip alarms that already have non-empty `alarmActions`. */ skipIfAlreadyConfigured?: boolean; } /** * Registers a CDK {@link https://docs.aws.amazon.com/cdk/v2/guide/aspects.html | Aspect} * on `scope` that attaches CloudWatch alarm actions to every `Alarm` and * `CompositeAlarm` (L2) construct in the subtree at synth time. Call once * with any scope — an `App`, a `Stack`, or the scope passed to `.build()` * for a composed system; alarms added after the call still pick up the * policy, so call ordering is irrelevant as * long as it happens before `app.synth()`. In particular, there is no need * to wrap this call in `afterBuild` — the Aspect runs after the construct * tree is finalised, not at call time. The only temporal constraint is that * any `IAlarmAction` instances in `config` (e.g. `new SnsAction(topic)`) * must reference constructs that already exist when the policy is called. * * Detection uses the version-portable `isCfnAlarm` / `isCfnCompositeAlarm` * guards (`CfnResource.isCfnResource` + `cfnResourceType`, so they work below * aws-cdk-lib 2.231.0) on the L1 resource; the L2 parent is found via * duck-typing on `addAlarmAction`. Actions are attached through * the L2 so that `IAlarmAction.bind()` runs and permissions are wired * correctly. Bare `CfnAlarm` nodes (created without an L2 wrapper) are * detected but silently skipped. * * `defaults` apply to every matched alarm; `rules` append additional actions. * A rule matches if any of its `match` entries matches. Set * `replaceDefaults: true` on a rule to suppress defaults for its matched * alarms. * * @example * ```ts * alarmActionsPolicy(app, { * defaults: { alarmActions: [new SnsAction(standardTopic)] }, * rules: [ * { match: "HighSev", alarmActions: [new SnsAction(pagerTopic)] }, * ], * }); * ``` */ export declare function alarmActionsPolicy(scope: IConstruct, config: AlarmActionsPolicyConfig): void; //# sourceMappingURL=alarm-actions-policy.d.ts.map