Class: AWSCDK::Events::RuleProps

Inherits:
EventCommonOptions
  • Object
show all
Defined in:
events/rule_props.rb

Overview

Properties for defining an EventBridge Rule.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cross_stack_scope: nil, description: nil, event_pattern: nil, rule_name: nil, enabled: nil, event_bus: nil, role: nil, schedule: nil, targets: nil) ⇒ RuleProps

Returns a new instance of RuleProps.

Parameters:

  • cross_stack_scope (Constructs::Construct, nil) (defaults to: nil)

    The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region).

  • description (String, nil) (defaults to: nil)

    A description of the rule's purpose.

  • event_pattern (AWSCDK::Events::EventPattern, nil) (defaults to: nil)

    Additional restrictions for the event to route to the specified target.

  • rule_name (String, nil) (defaults to: nil)

    A name for the rule.

  • enabled (Boolean, nil) (defaults to: nil)

    Indicates whether the rule is enabled.

  • event_bus (AWSCDK::Interfaces::AWSEvents::IEventBusRef, nil) (defaults to: nil)

    The event bus to associate with this rule.

  • role (AWSCDK::Interfaces::AWSIAM::IRoleRef, nil) (defaults to: nil)

    The role that is used for target invocation.

  • schedule (AWSCDK::Events::Schedule, nil) (defaults to: nil)

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

  • targets (Array<AWSCDK::Events::IRuleTarget>, nil) (defaults to: nil)

    Targets to invoke when this rule matches an event.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'events/rule_props.rb', line 16

def initialize(cross_stack_scope: nil, description: nil, event_pattern: nil, rule_name: nil, enabled: nil, event_bus: nil, role: nil, schedule: nil, targets: nil)
  @cross_stack_scope = cross_stack_scope
  Jsii::Type.check_type(@cross_stack_scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "crossStackScope") unless @cross_stack_scope.nil?
  @description = description
  Jsii::Type.check_type(@description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless @description.nil?
  @event_pattern = event_pattern.is_a?(Hash) ? ::AWSCDK::Events::EventPattern.new(**event_pattern.transform_keys(&:to_sym)) : event_pattern
  Jsii::Type.check_type(@event_pattern, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZXZlbnRzLkV2ZW50UGF0dGVybiJ9")), "eventPattern") unless @event_pattern.nil?
  @rule_name = rule_name
  Jsii::Type.check_type(@rule_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "ruleName") unless @rule_name.nil?
  @enabled = enabled
  Jsii::Type.check_type(@enabled, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "enabled") unless @enabled.nil?
  @event_bus = event_bus
  Jsii::Type.check_type(@event_bus, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19ldmVudHMuSUV2ZW50QnVzUmVmIn0=")), "eventBus") unless @event_bus.nil?
  @role = role
  Jsii::Type.check_type(@role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19pYW0uSVJvbGVSZWYifQ==")), "role") unless @role.nil?
  @schedule = schedule
  Jsii::Type.check_type(@schedule, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZXZlbnRzLlNjaGVkdWxlIn0=")), "schedule") unless @schedule.nil?
  @targets = targets
  Jsii::Type.check_type(@targets, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19ldmVudHMuSVJ1bGVUYXJnZXQifSwia2luZCI6ImFycmF5In19")), "targets") unless @targets.nil?
end

Instance Attribute Details

#cross_stack_scopeConstructs::Construct? (readonly)

Note:

Default: - none (the main scope will be used, even for cross-stack Events)

The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region).

This helps dealing with cycles that often arise in these situations.

Returns:

  • (Constructs::Construct, nil)


43
44
45
# File 'events/rule_props.rb', line 43

def cross_stack_scope
  @cross_stack_scope
end

#descriptionString? (readonly)

Note:

Default: - No description

A description of the rule's purpose.

Returns:

  • (String, nil)


48
49
50
# File 'events/rule_props.rb', line 48

def description
  @description
end

#enabledBoolean? (readonly)

Note:

Default: true

Indicates whether the rule is enabled.

Returns:

  • (Boolean, nil)


68
69
70
# File 'events/rule_props.rb', line 68

def enabled
  @enabled
end

#event_busAWSCDK::Interfaces::AWSEvents::IEventBusRef? (readonly)

Note:

Default: - The default event bus.

The event bus to associate with this rule.



73
74
75
# File 'events/rule_props.rb', line 73

def event_bus
  @event_bus
end

#event_patternAWSCDK::Events::EventPattern? (readonly)

Note:

Default: - No additional filtering based on an event pattern.

Additional restrictions for the event to route to the specified target.

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.



58
59
60
# File 'events/rule_props.rb', line 58

def event_pattern
  @event_pattern
end

#roleAWSCDK::Interfaces::AWSIAM::IRoleRef? (readonly)

Note:

Default: - No role associated

The role that is used for target invocation.

Must be assumable by principal events.amazonaws.com.



80
81
82
# File 'events/rule_props.rb', line 80

def role
  @role
end

#rule_nameString? (readonly)

Note:

Default: AWS CloudFormation generates a unique physical ID.

A name for the rule.

Returns:

  • (String, nil)


63
64
65
# File 'events/rule_props.rb', line 63

def rule_name
  @rule_name
end

#scheduleAWSCDK::Events::Schedule? (readonly)

Note:

Default: - None.

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

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

For more information, see Schedule Expression Syntax for Rules in the Amazon EventBridge User Guide.



91
92
93
# File 'events/rule_props.rb', line 91

def schedule
  @schedule
end

#targetsArray<AWSCDK::Events::IRuleTarget>? (readonly)

Note:

Default: - No 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]).

Returns:



99
100
101
# File 'events/rule_props.rb', line 99

def targets
  @targets
end

Class Method Details

.jsii_propertiesObject



101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'events/rule_props.rb', line 101

def self.jsii_properties
  {
    :cross_stack_scope => "crossStackScope",
    :description => "description",
    :event_pattern => "eventPattern",
    :rule_name => "ruleName",
    :enabled => "enabled",
    :event_bus => "eventBus",
    :role => "role",
    :schedule => "schedule",
    :targets => "targets",
  }
end

Instance Method Details

#to_jsiiObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'events/rule_props.rb', line 115

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "crossStackScope" => @cross_stack_scope,
    "description" => @description,
    "eventPattern" => @event_pattern,
    "ruleName" => @rule_name,
    "enabled" => @enabled,
    "eventBus" => @event_bus,
    "role" => @role,
    "schedule" => @schedule,
    "targets" => @targets,
  })
  result.compact
end