Class: AWSCDK::Events::EventPattern

Inherits:
Jsii::Struct
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • account (Array<String>, nil) (defaults to: nil)

    The 12-digit number identifying an AWS account.

  • detail (Hash{String => Object}, nil) (defaults to: nil)

    A JSON object, whose content is at the discretion of the service originating the event.

  • detail_type (Array<String>, nil) (defaults to: nil)

    Identifies, in combination with the source field, the fields and values that appear in the detail field.

  • id (Array<String>, nil) (defaults to: nil)

    A unique value is generated for every event.

  • region (Array<String>, nil) (defaults to: nil)

    Identifies the AWS region where the event originated.

  • resources (Array<String>, nil) (defaults to: nil)

    This JSON array contains ARNs that identify resources that are involved in the event.

  • source (Array<String>, nil) (defaults to: nil)

    Identifies the service that sourced the event.

  • time (Array<String>, nil) (defaults to: nil)

    The event timestamp, which can be specified by the service originating the event.

  • version (Array<String>, nil) (defaults to: nil)

    By default, this is set to 0 (zero) in all events.



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 = 
  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

#accountArray<String>? (readonly)

Note:

Default: - No filtering on account

The 12-digit number identifying an AWS account.

Returns:

  • (Array<String>, nil)


64
65
66
# File 'events/event_pattern.rb', line 64

def 
  @account
end

#detailHash{String => Object}? (readonly)

Note:

Default: - No filtering on detail

A JSON object, whose content is at the discretion of the service originating the event.

Returns:

  • (Hash{String => Object}, nil)


69
70
71
# File 'events/event_pattern.rb', line 69

def detail
  @detail
end

#detail_typeArray<String>? (readonly)

Note:

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.

Returns:

  • (Array<String>, nil)


76
77
78
# File 'events/event_pattern.rb', line 76

def detail_type
  @detail_type
end

#idArray<String>? (readonly)

Note:

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.

Returns:

  • (Array<String>, nil)


84
85
86
# File 'events/event_pattern.rb', line 84

def id
  @id
end

#regionArray<String>? (readonly)

Note:

Default: - No filtering on region

Identifies the AWS region where the event originated.

Returns:

  • (Array<String>, nil)


89
90
91
# File 'events/event_pattern.rb', line 89

def region
  @region
end

#resourcesArray<String>? (readonly)

Note:

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.

Returns:

  • (Array<String>, nil)


102
103
104
# File 'events/event_pattern.rb', line 102

def resources
  @resources
end

#sourceArray<String>? (readonly)

Note:

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

#timeArray<String>? (readonly)

Note:

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.

Returns:

  • (Array<String>, nil)


126
127
128
# File 'events/event_pattern.rb', line 126

def time
  @time
end

#versionArray<String>? (readonly)

Note:

Default: - No filtering on version

By default, this is set to 0 (zero) in all events.

Returns:

  • (Array<String>, nil)


131
132
133
# File 'events/event_pattern.rb', line 131

def version
  @version
end

Class Method Details

.jsii_propertiesObject



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_jsiiObject



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