cloud watch alarmを簡単に全削除

投稿者: | 2018年6月7日

cloud watch alarmの削除はAWSCLIで実施するのが一番簡単です。
CLIでは下記のコマンドでアラーム一覧取得と削除ができます。

$ aws cloudwatch describe-alarms --profile XXXXX
$ aws cloudwatch delete-alarms --alarm-names XXXXXXXXXXXXXX --profile XXXXX

コマンドはアラーム名だけ指定すれば実行可能です。
なお、デフォルトのprofileを使用する場合は「–profile」オプションは不要です。
従って、下記のようにアラーム名の一覧を取得し、そこからコマンドを実行すれば簡単に削除できます。

aws cloudwatch describe-alarms --profile meti | grep AlarmName > alarmList.txt
sed -e "s/            \"AlarmName\": \"/aws cloudwatch delete-alarms --alarm-names /g" alarmList.txt > ./tmp.txt
sed -e "s/\",/ --profile XXXXX/g" tmp.txt > deleteAlarm.sh
sh deleteAlarm.sh

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA