@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:39.310Z") @Stability(value=Stable) public class Rule extends Resource implements IRule
Example:
import software.amazon.awscdk.services.lambda.*;
Function fn = Function.Builder.create(this, "MyFunc")
.runtime(Runtime.NODEJS_14_X)
.handler("index.handler")
.code(Code.fromInline("exports.handler = handler.toString()"))
.build();
Rule rule = Rule.Builder.create(this, "rule")
.eventPattern(EventPattern.builder()
.source(List.of("aws.ec2"))
.build())
.build();
Queue queue = new Queue(this, "Queue");
rule.addTarget(LambdaFunction.Builder.create(fn)
.deadLetterQueue(queue) // Optional: add a dead letter queue
.maxEventAge(Duration.hours(2)) // Optional: set the maxEventAge retry policy
.retryAttempts(2)
.build());
| Modifier and Type | Class and Description |
|---|---|
static class |
Rule.Builder
A fluent builder for
Rule. |
software.amazon.jsii.JsiiObject.InitializationModeIRule.Jsii$Default, IRule.Jsii$Proxy| Modifier | Constructor and Description |
|---|---|
|
Rule(software.constructs.Construct scope,
String id) |
|
Rule(software.constructs.Construct scope,
String id,
RuleProps props) |
protected |
Rule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Rule(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventPattern()
Adds an event pattern filter to this rule.
|
void |
addEventPattern(EventPattern eventPattern)
Adds an event pattern filter to this rule.
|
void |
addTarget()
Adds a target to the rule.
|
void |
addTarget(IRuleTarget target)
Adds a target to the rule.
|
static IRule |
fromEventRuleArn(software.constructs.Construct scope,
String id,
String eventRuleArn)
Import an existing EventBridge Rule provided an ARN.
|
String |
getRuleArn()
The value of the event rule Amazon Resource Name (ARN), such as arn:aws:events:us-east-2:123456789012:rule/example.
|
String |
getRuleName()
The name event rule.
|
protected List<String> |
validateRule() |
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourcejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitapplyRemovalPolicy, getEnv, getStackprotected Rule(software.amazon.jsii.JsiiObjectRef objRef)
protected Rule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public Rule(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@Nullable
RuleProps props)
scope - This parameter is required.id - This parameter is required.props - @Stability(value=Stable)
public Rule(@NotNull
software.constructs.Construct scope,
@NotNull
String id)
scope - This parameter is required.id - This parameter is required.@Stability(value=Stable) @NotNull public static IRule fromEventRuleArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String eventRuleArn)
scope - The parent creating construct (usually `this`). This parameter is required.id - The construct's name. This parameter is required.eventRuleArn - Event Rule ARN (i.e. arn:aws:events:@Stability(value=Stable)
public void addEventPattern(@Nullable
EventPattern eventPattern)
If a pattern was already specified, these values are merged into the existing pattern.
For example, if the rule already contains the pattern:
{
"resources": [ "r1" ],
"detail": {
"hello": [ 1 ]
}
}
And addEventPattern is called with the pattern:
{
"resources": [ "r2" ],
"detail": {
"foo": [ "bar" ]
}
}
The resulting event pattern will be:
{
"resources": [ "r1", "r2" ],
"detail": {
"hello": [ 1 ],
"foo": [ "bar" ]
}
}
eventPattern - @Stability(value=Stable) public void addEventPattern()
If a pattern was already specified, these values are merged into the existing pattern.
For example, if the rule already contains the pattern:
{
"resources": [ "r1" ],
"detail": {
"hello": [ 1 ]
}
}
And addEventPattern is called with the pattern:
{
"resources": [ "r2" ],
"detail": {
"foo": [ "bar" ]
}
}
The resulting event pattern will be:
{
"resources": [ "r1", "r2" ],
"detail": {
"hello": [ 1 ],
"foo": [ "bar" ]
}
}
@Stability(value=Stable)
public void addTarget(@Nullable
IRuleTarget target)
No-op if target is undefined.
target - @Stability(value=Stable) public void addTarget()
No-op if target is undefined.
@Stability(value=Stable) @NotNull public String getRuleArn()
getRuleArn in interface IRule@Stability(value=Stable) @NotNull public String getRuleName()
getRuleName in interface IRuleCopyright © 2022. All rights reserved.