Class RuleProps
Properties for defining an EventBridge Rule.
Inheritance
Namespace: Amazon.CDK.AWS.Events
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class RuleProps : Object, IRuleProps, IEventCommonOptions
Syntax (vb)
Public Class RuleProps
Inherits Object
Implements IRuleProps, IEventCommonOptions
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.Lambda;
var fn = new Function(this, "MyFunc", new FunctionProps {
Runtime = Runtime.NODEJS_LATEST,
Handler = "index.handler",
Code = Code.FromInline("exports.handler = handler.toString()")
});
var rule = new Rule(this, "rule", new RuleProps {
EventPattern = new EventPattern {
Source = new [] { "aws.ec2" }
}
});
var queue = new Queue(this, "Queue");
rule.AddTarget(new LambdaFunction(fn, new LambdaFunctionProps {
DeadLetterQueue = queue, // Optional: add a dead letter queue
MaxEventAge = Duration.Hours(2), // Optional: set the maxEventAge retry policy
RetryAttempts = 2
}));
Synopsis
Constructors
RuleProps() |
Properties
CrossStackScope | The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). |
Description | A description of the rule's purpose. |
Enabled | Indicates whether the rule is enabled. |
EventBus | The event bus to associate with this rule. |
EventPattern | Additional restrictions for the event to route to the specified target. |
RuleName | A name for the rule. |
Schedule | The schedule or rate (frequency) that determines when EventBridge runs the rule. |
Targets | Targets to invoke when this rule matches an event. |
Constructors
RuleProps()
public RuleProps()
Properties
CrossStackScope
The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region).
public Construct CrossStackScope { get; set; }
Property Value
Constructs.Construct
Remarks
This helps dealing with cycles that often arise in these situations.
Default: - none (the main scope will be used, even for cross-stack Events)
Description
A description of the rule's purpose.
public string Description { get; set; }
Property Value
System.String
Remarks
Default: - No description
Enabled
Indicates whether the rule is enabled.
public Nullable<bool> Enabled { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: true
EventBus
The event bus to associate with this rule.
public IEventBus EventBus { get; set; }
Property Value
Remarks
Default: - The default event bus.
EventPattern
Additional restrictions for the event to route to the specified target.
public IEventPattern EventPattern { get; set; }
Property Value
Remarks
The method that generates the rule probably imposes some type of event filtering. The filtering implied by what you pass here is added on top of that filtering.
Default: - No additional filtering based on an event pattern.
RuleName
A name for the rule.
public string RuleName { get; set; }
Property Value
System.String
Remarks
Default: AWS CloudFormation generates a unique physical ID.
Schedule
The schedule or rate (frequency) that determines when EventBridge runs the rule.
public Schedule Schedule { get; set; }
Property Value
Remarks
You must specify this property, the eventPattern
property, or both.
For more information, see Schedule Expression Syntax for Rules in the Amazon EventBridge User Guide.
Default: - None.
See: https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html
Targets
Targets to invoke when this rule matches an event.
public IRuleTarget[] Targets { get; set; }
Property Value
Remarks
Input will be the full matched event. If you wish to specify custom
target input, use addTarget(target[, inputOptions])
.
Default: - No targets.