1 | import { Resource } from '@aws-cdk/core';
|
2 | import { Construct } from 'constructs';
|
3 | import { IEventBus } from './event-bus';
|
4 | import { EventPattern } from './event-pattern';
|
5 | import { IRule } from './rule-ref';
|
6 | import { Schedule } from './schedule';
|
7 | import { IRuleTarget } from './target';
|
8 | /**
|
9 | * Properties for defining an EventBridge Rule
|
10 | */
|
11 | export interface RuleProps {
|
12 | /**
|
13 | * A description of the rule's purpose.
|
14 | *
|
15 | * @default - No description.
|
16 | */
|
17 | readonly description?: string;
|
18 | /**
|
19 | * A name for the rule.
|
20 | *
|
21 | * @default - AWS CloudFormation generates a unique physical ID and uses that ID
|
22 | * for the rule name. For more information, see Name Type.
|
23 | */
|
24 | readonly ruleName?: string;
|
25 | /**
|
26 | * Indicates whether the rule is enabled.
|
27 | *
|
28 | * @default true
|
29 | */
|
30 | readonly enabled?: boolean;
|
31 | /**
|
32 | * The schedule or rate (frequency) that determines when EventBridge
|
33 | * runs the rule. For more information, see Schedule Expression Syntax for
|
34 | * Rules in the Amazon EventBridge User Guide.
|
35 | *
|
36 | * @see https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html
|
37 | *
|
38 | * You must specify this property, the `eventPattern` property, or both.
|
39 | *
|
40 | * @default - None.
|
41 | */
|
42 | readonly schedule?: Schedule;
|
43 | /**
|
44 | * Describes which events EventBridge routes to the specified target.
|
45 | * These routed events are matched events. For more information, see Events
|
46 | * and Event Patterns in the Amazon EventBridge User Guide.
|
47 | *
|
48 | * @see
|
49 | * https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html
|
50 | *
|
51 | * You must specify this property (either via props or via
|
52 | * `addEventPattern`), the `scheduleExpression` property, or both. The
|
53 | * method `addEventPattern` can be used to add filter values to the event
|
54 | * pattern.
|
55 | *
|
56 | * @default - None.
|
57 | */
|
58 | readonly eventPattern?: EventPattern;
|
59 | /**
|
60 | * Targets to invoke when this rule matches an event.
|
61 | *
|
62 | * Input will be the full matched event. If you wish to specify custom
|
63 | * target input, use `addTarget(target[, inputOptions])`.
|
64 | *
|
65 | * @default - No targets.
|
66 | */
|
67 | readonly targets?: IRuleTarget[];
|
68 | /**
|
69 | * The event bus to associate with this rule.
|
70 | *
|
71 | * @default - The default event bus.
|
72 | */
|
73 | readonly eventBus?: IEventBus;
|
74 | }
|
75 | /**
|
76 | * Defines an EventBridge Rule in this stack.
|
77 | *
|
78 | * @resource AWS::Events::Rule
|
79 | */
|
80 | export declare class Rule extends Resource implements IRule {
|
81 | /**
|
82 | * Import an existing EventBridge Rule provided an ARN
|
83 | *
|
84 | * @param scope The parent creating construct (usually `this`).
|
85 | * @param id The construct's name.
|
86 | * @param eventRuleArn Event Rule ARN (i.e. arn:aws:events:<region>:<account-id>:rule/MyScheduledRule).
|
87 | */
|
88 | static fromEventRuleArn(scope: Construct, id: string, eventRuleArn: string): IRule;
|
89 | readonly ruleArn: string;
|
90 | readonly ruleName: string;
|
91 | private readonly targets;
|
92 | private readonly eventPattern;
|
93 | private readonly scheduleExpression?;
|
94 | private readonly description?;
|
95 | /** Set to keep track of what target accounts and regions we've already created event buses for */
|
96 | private readonly _xEnvTargetsAdded;
|
97 | constructor(scope: Construct, id: string, props?: RuleProps);
|
98 | /**
|
99 | * Adds a target to the rule. The abstract class RuleTarget can be extended to define new
|
100 | * targets.
|
101 | *
|
102 | * No-op if target is undefined.
|
103 | */
|
104 | addTarget(target?: IRuleTarget): void;
|
105 | /**
|
106 | * Adds an event pattern filter to this rule. If a pattern was already specified,
|
107 | * these values are merged into the existing pattern.
|
108 | *
|
109 | * For example, if the rule already contains the pattern:
|
110 | *
|
111 | * {
|
112 | * "resources": [ "r1" ],
|
113 | * "detail": {
|
114 | * "hello": [ 1 ]
|
115 | * }
|
116 | * }
|
117 | *
|
118 | * And `addEventPattern` is called with the pattern:
|
119 | *
|
120 | * {
|
121 | * "resources": [ "r2" ],
|
122 | * "detail": {
|
123 | * "foo": [ "bar" ]
|
124 | * }
|
125 | * }
|
126 | *
|
127 | * The resulting event pattern will be:
|
128 | *
|
129 | * {
|
130 | * "resources": [ "r1", "r2" ],
|
131 | * "detail": {
|
132 | * "hello": [ 1 ],
|
133 | * "foo": [ "bar" ]
|
134 | * }
|
135 | * }
|
136 | *
|
137 | */
|
138 | addEventPattern(eventPattern?: EventPattern): void;
|
139 | /**
|
140 | * Not private only to be overrideen in CopyRule.
|
141 | *
|
142 | * @internal
|
143 | */
|
144 | _renderEventPattern(): any;
|
145 | protected validate(): string[];
|
146 | private renderTargets;
|
147 | /**
|
148 | * Make sure we add the target environments event bus as a target, and the target has permissions set up to receive our events
|
149 | *
|
150 | * For cross-account rules, uses a support stack to set up a policy on the target event bus.
|
151 | */
|
152 | private ensureXEnvTargetEventBus;
|
153 | /**
|
154 | * Return the scope where the mirror rule should be created for x-env event targets
|
155 | *
|
156 | * This is the target resource's containing stack if it shares the same region (owned
|
157 | * resources), or should be a fresh support stack for imported resources.
|
158 | *
|
159 | * We don't implement the second yet, as I have to think long and hard on whether we
|
160 | * can reuse the existing support stack or not, and I don't have time for that right now.
|
161 | */
|
162 | private obtainMirrorRuleScope;
|
163 | /**
|
164 | * Obtain the Role for the EventBridge event
|
165 | *
|
166 | * If a role already exists, it will be returned. This ensures that if multiple
|
167 | * events have the same target, they will share a role.
|
168 | * @internal
|
169 | */
|
170 | private crossRegionPutEventsRole;
|
171 | }
|