RuleProps

class aws_cdk.aws_events.RuleProps(*, description=None, enabled=None, event_bus=None, event_pattern=None, rule_name=None, schedule=None, targets=None)

Bases: object

Properties for defining an EventBridge Rule.

Parameters:
  • description (Optional[str]) – A description of the rule’s purpose. Default: - No description.

  • enabled (Optional[bool]) – Indicates whether the rule is enabled. Default: true

  • event_bus (Optional[IEventBus]) – The event bus to associate with this rule. Default: - The default event bus.

  • event_pattern (Union[EventPattern, Dict[str, Any], None]) – Describes which events EventBridge routes to the specified target. These routed events are matched events. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide. Default: - None.

  • rule_name (Optional[str]) – A name for the rule. Default: - AWS CloudFormation generates a unique physical ID and uses that ID for the rule name. For more information, see Name Type.

  • schedule (Optional[Schedule]) – The schedule or rate (frequency) that determines when EventBridge runs the rule. For more information, see Schedule Expression Syntax for Rules in the Amazon EventBridge User Guide. Default: - None.

  • targets (Optional[Sequence[IRuleTarget]]) – Targets to invoke when this rule matches an event. Input will be the full matched event. If you wish to specify custom target input, use addTarget(target[, inputOptions]). Default: - No targets.

ExampleMetadata:

infused

Example:

connection = events.Connection(self, "Connection",
    authorization=events.Authorization.api_key("x-api-key", SecretValue.secrets_manager("ApiSecretName")),
    description="Connection with API Key x-api-key"
)

destination = events.ApiDestination(self, "Destination",
    connection=connection,
    endpoint="https://example.com",
    description="Calling example.com with API key x-api-key"
)

rule = events.Rule(self, "Rule",
    schedule=events.Schedule.rate(cdk.Duration.minutes(1)),
    targets=[targets.ApiDestination(destination)]
)

Attributes

description

A description of the rule’s purpose.

Default:
  • No description.

enabled

Indicates whether the rule is enabled.

Default:

true

event_bus

The event bus to associate with this rule.

Default:
  • The default event bus.

event_pattern

Describes which events EventBridge routes to the specified target.

These routed events are matched events. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide.

Default:
  • None.

See:

https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html

You must specify this property (either via props or via addEventPattern), the scheduleExpression property, or both. The method addEventPattern can be used to add filter values to the event pattern.

rule_name

A name for the rule.

Default:

  • AWS CloudFormation generates a unique physical ID and uses that ID

for the rule name. For more information, see Name Type.

schedule

The schedule or rate (frequency) that determines when EventBridge runs the rule.

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

You must specify this property, the eventPattern property, or both.

targets

Targets to invoke when this rule matches an event.

Input will be the full matched event. If you wish to specify custom target input, use addTarget(target[, inputOptions]).

Default:
  • No targets.