0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

不要となったCloudWatchAlarmを一括削除する

Posted at

3000件以上あった不要となったCloudWatchAlarmを、シェルスクリプトで削除します。

#!/bin/sh

#``ではなく$()を使う
list=$(aws cloudwatch describe-alarms --alarm-name-prefix ip- --output=text --query 'MetricAlarms[].AlarmName' --max-items 5)
##echo "$list"
for name in $list
do
if [ `echo "$name" | grep 'Processlist'` ] ; then
  echo "$name"
  aws cloudwatch delete-alarms --alarm-names $nam
fi
done

  1. 「ip-」のprefixを持つアラーム一覧を取得する
  2. queryでAlarmNameだけを取得する
  3. Processlistが含まれていれば、削除する
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?