Module: Awspec::Helper::Finder::Cloudwatch

Included in:
Awspec::Helper::Finder
Defined in:
lib/awspec/helper/finder/cloudwatch.rb

Instance Method Summary collapse

Instance Method Details

#find_cloudwatch_alarm(id) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/awspec/helper/finder/cloudwatch.rb', line 4

def find_cloudwatch_alarm(id)
  res = @cloudwatch_client.describe_alarms({
                                             alarm_names: [id]
                                           })
  return res[:metric_alarms].first if res[:metric_alarms].count == 1

  res = @cloudwatch_client.describe_alarms
  res[:metric_alarms].find do |alarm|
    alarm[:alarm_arn] == id
  end
end