Created
November 28, 2016 18:16
-
-
Save noqcks/bdf78aad4a0340f4f2b19f0dcb8588ed to your computer and use it in GitHub Desktop.
Delete all cloudwatch alarms with insufficient data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
@client = Aws::CloudWatch::Client.new(region: 'us-east-1') | |
def cloudwatch_alarms(token=nil) | |
return @client.describe_alarms({ | |
state_value: "INSUFFICIENT_DATA", | |
next_token: token | |
}) | |
end | |
def delete(token=nil) | |
resp = cloudwatch_alarms(token) | |
alarm_names = [] | |
resp.metric_alarms.each do |alarm| | |
alarm_names << alarm.alarm_name | |
end | |
res = @client.delete_alarms({ | |
alarm_names: alarm_names, | |
}) | |
delete(resp.next_token) | |
end | |
delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment