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 15 |
# 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 alarms = res.metric_alarms.select do |alarm| alarm.alarm_arn == id end alarms.single_resource(id) end |
#select_all_cloudwatch_alarms ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/awspec/helper/finder/cloudwatch.rb', line 17 def select_all_cloudwatch_alarms selected = [] res = cloudwatch_client.describe_alarms loop do selected += res.metric_alarms break if res.next_token.nil? res = cloudwatch_client.describe_alarms({ next_token: res.next_token }) end selected end |