Class: AWSCDK::Events::EventPattern
- Inherits:
-
Jsii::Struct
- Object
- Jsii::Struct
- AWSCDK::Events::EventPattern
- Defined in:
- events/event_pattern.rb
Overview
Events in Amazon CloudWatch Events are represented as JSON objects. For more information about JSON objects, see RFC 7159.
Rules use event patterns to select events and route them to targets. A pattern either matches an event or it doesn't. Event patterns are represented as JSON objects with a structure that is similar to that of events.
It is important to remember the following about event pattern matching:
- For a pattern to match an event, the event must contain all the field names listed in the pattern. The field names must appear in the event with the same nesting structure.
- Other fields of the event not mentioned in the pattern are ignored;
effectively, there is a
"*": "*"wildcard for fields not mentioned. - The matching is exact (character-by-character), without case-folding or any other string normalization.
- The values being matched follow JSON rules: Strings enclosed in quotes, numbers, and the unquoted keywords true, false, and null.
- Number matching is at the string representation level. For example, 300, 300.0, and 3.0e2 are not considered equal.
For custom events, some optional properties are required. For more information, see Minimum information needed for a valid custom event.
Instance Attribute Summary collapse
-
#account ⇒ Array<String>?
readonly
The 12-digit number identifying an AWS account.
-
#detail ⇒ Hash{String => Object}?
readonly
A JSON object, whose content is at the discretion of the service originating the event.
-
#detail_type ⇒ Array<String>?
readonly
Identifies, in combination with the source field, the fields and values that appear in the detail field.
-
#id ⇒ Array<String>?
readonly
A unique value is generated for every event.
-
#region ⇒ Array<String>?
readonly
Identifies the AWS region where the event originated.
-
#resources ⇒ Array<String>?
readonly
This JSON array contains ARNs that identify resources that are involved in the event.
-
#source ⇒ Array<String>?
readonly
Identifies the service that sourced the event.
-
#time ⇒ Array<String>?
readonly
The event timestamp, which can be specified by the service originating the event.
-
#version ⇒ Array<String>?
readonly
By default, this is set to 0 (zero) in all events.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(account: nil, detail: nil, detail_type: nil, id: nil, region: nil, resources: nil, source: nil, time: nil, version: nil) ⇒ EventPattern
constructor
A new instance of EventPattern.
- #to_jsii ⇒ Object
Constructor Details
#initialize(account: nil, detail: nil, detail_type: nil, id: nil, region: nil, resources: nil, source: nil, time: nil, version: nil) ⇒ EventPattern
Returns a new instance of EventPattern.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'events/event_pattern.rb', line 39 def initialize(account: nil, detail: nil, detail_type: nil, id: nil, region: nil, resources: nil, source: nil, time: nil, version: nil) @account = account Jsii::Type.check_type(@account, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "account") unless @account.nil? @detail = detail Jsii::Type.check_type(@detail, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6ImFueSJ9LCJraW5kIjoibWFwIn19")), "detail") unless @detail.nil? @detail_type = detail_type Jsii::Type.check_type(@detail_type, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "detailType") unless @detail_type.nil? @id = id Jsii::Type.check_type(@id, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "id") unless @id.nil? @region = region Jsii::Type.check_type(@region, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "region") unless @region.nil? @resources = resources Jsii::Type.check_type(@resources, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "resources") unless @resources.nil? @source = source Jsii::Type.check_type(@source, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "source") unless @source.nil? @time = time Jsii::Type.check_type(@time, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "time") unless @time.nil? @version = version Jsii::Type.check_type(@version, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "version") unless @version.nil? end |
Instance Attribute Details
#account ⇒ Array<String>? (readonly)
Default: - No filtering on account
The 12-digit number identifying an AWS account.
64 65 66 |
# File 'events/event_pattern.rb', line 64 def account @account end |
#detail ⇒ Hash{String => Object}? (readonly)
Default: - No filtering on detail
A JSON object, whose content is at the discretion of the service originating the event.
69 70 71 |
# File 'events/event_pattern.rb', line 69 def detail @detail end |
#detail_type ⇒ Array<String>? (readonly)
Default: - No filtering on detail type
Identifies, in combination with the source field, the fields and values that appear in the detail field.
Represents the "detail-type" event field.
76 77 78 |
# File 'events/event_pattern.rb', line 76 def detail_type @detail_type end |
#id ⇒ Array<String>? (readonly)
Default: - No filtering on id
A unique value is generated for every event.
This can be helpful in tracing events as they move through rules to targets, and are processed.
84 85 86 |
# File 'events/event_pattern.rb', line 84 def id @id end |
#region ⇒ Array<String>? (readonly)
Default: - No filtering on region
Identifies the AWS region where the event originated.
89 90 91 |
# File 'events/event_pattern.rb', line 89 def region @region end |
#resources ⇒ Array<String>? (readonly)
Default: - No filtering on resource
This JSON array contains ARNs that identify resources that are involved in the event.
Inclusion of these ARNs is at the discretion of the service.
For example, Amazon EC2 instance state-changes include Amazon EC2 instance ARNs, Auto Scaling events include ARNs for both instances and Auto Scaling groups, but API calls with AWS CloudTrail do not include resource ARNs.
102 103 104 |
# File 'events/event_pattern.rb', line 102 def resources @resources end |
#source ⇒ Array<String>? (readonly)
Default: - No filtering on source
Identifies the service that sourced the event.
All events sourced from within AWS begin with "aws." Customer-generated events can have any value here, as long as it doesn't begin with "aws." We recommend the use of Java package-name style reverse domain-name strings.
To find the correct value for source for an AWS service, see the table in AWS Service Namespaces. For example, the source value for Amazon CloudFront is aws.cloudfront.
117 118 119 |
# File 'events/event_pattern.rb', line 117 def source @source end |
#time ⇒ Array<String>? (readonly)
Default: - No filtering on time
The event timestamp, which can be specified by the service originating the event.
If the event spans a time interval, the service might choose to report the start time, so this value can be noticeably before the time the event is actually received.
126 127 128 |
# File 'events/event_pattern.rb', line 126 def time @time end |
#version ⇒ Array<String>? (readonly)
Default: - No filtering on version
By default, this is set to 0 (zero) in all events.
131 132 133 |
# File 'events/event_pattern.rb', line 131 def version @version end |
Class Method Details
.jsii_properties ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'events/event_pattern.rb', line 133 def self.jsii_properties { :account => "account", :detail => "detail", :detail_type => "detailType", :id => "id", :region => "region", :resources => "resources", :source => "source", :time => "time", :version => "version", } end |
Instance Method Details
#to_jsii ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'events/event_pattern.rb', line 147 def to_jsii result = {} result.merge!({ "account" => @account, "detail" => @detail, "detailType" => @detail_type, "id" => @id, "region" => @region, "resources" => @resources, "source" => @source, "time" => @time, "version" => @version, }) result.compact end |