@Generated(value="jsii-pacmak/1.73.0 (build 6faeda3)", date="2023-01-31T18:36:51.446Z") 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 . |
IRule.Jsii$Default, IRule.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
protected |
Rule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Rule(software.amazon.jsii.JsiiObjectRef objRef) |
|
Rule(software.constructs.Construct scope,
java.lang.String id) |
|
Rule(software.constructs.Construct scope,
java.lang.String id,
RuleProps props) |
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,
java.lang.String id,
java.lang.String eventRuleArn)
Import an existing EventBridge Rule provided an ARN.
|
java.lang.String |
getRuleArn()
The value of the event rule Amazon Resource Name (ARN), such as arn:aws:events:us-east-2:123456789012:rule/example.
|
java.lang.String |
getRuleName()
The name event rule.
|
protected java.util.List<java.lang.String> |
validate()
Validate the current construct.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResource
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyRemovalPolicy, getEnv, getStack
getNode
protected Rule(software.amazon.jsii.JsiiObjectRef objRef)
protected Rule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public Rule(software.constructs.Construct scope, java.lang.String id, RuleProps props)
scope
- This parameter is required.id
- This parameter is required.props
- public Rule(software.constructs.Construct scope, java.lang.String id)
scope
- This parameter is required.id
- This parameter is required.public static IRule fromEventRuleArn(software.constructs.Construct scope, java.lang.String id, java.lang.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:public void addEventPattern(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
- 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" ] } }
public void addTarget(IRuleTarget target)
No-op if target is undefined.
target
- public void addTarget()
No-op if target is undefined.
protected java.util.List<java.lang.String> validate()
This method can be implemented by derived constructs in order to perform validation logic. It is called on all constructs before synthesis.
public java.lang.String getRuleArn()
getRuleArn
in interface IRule
public java.lang.String getRuleName()
getRuleName
in interface IRule