Class: OpenStax::Aws::EventRule

Inherits:
Object
  • Object
show all
Defined in:
lib/openstax/aws/event_rule.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, region:) ⇒ EventRule

Returns a new instance of EventRule.



11
12
13
14
15
# File 'lib/openstax/aws/event_rule.rb', line 11

def initialize(name:, region:)
  @client = Aws::EventBridge::Client.new region: region
  # There is no real rule wrapper in the SDK but the DescribeRuleResponse can be used
  @raw_rule = client.describe_rule name: name
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/openstax/aws/event_rule.rb', line 3

def client
  @client
end

#raw_ruleObject (readonly)

Returns the value of attribute raw_rule.



3
4
5
# File 'lib/openstax/aws/event_rule.rb', line 3

def raw_rule
  @raw_rule
end

Class Method Details

.physical_resource_id_attributeObject



7
8
9
# File 'lib/openstax/aws/event_rule.rb', line 7

def self.physical_resource_id_attribute
  :name
end

Instance Method Details

#add_tags_not_handled_by_cloudformation(stack_tags) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/openstax/aws/event_rule.rb', line 25

def add_tags_not_handled_by_cloudformation(stack_tags)
  missing_tags = stack_tags.map(&:to_h) - tags.map(&:to_h)

  return if missing_tags.empty?

  OpenStax::Aws.configuration.logger.debug "Tagging #{name}..."
  tag_resource missing_tags
end

#tag_resource(new_tags) ⇒ Object



21
22
23
# File 'lib/openstax/aws/event_rule.rb', line 21

def tag_resource(new_tags)
  client.tag_resource resource_arn: raw_rule.arn, tags: new_tags
end

#tagsObject



17
18
19
# File 'lib/openstax/aws/event_rule.rb', line 17

def tags
  client.list_tags_for_resource(resource_arn: raw_rule.arn).tags
end