はじめに
ローカルPCからAWS CLIを利用して、Amazon CloudWatchのアラームのステータスを強制的に変更し、Slackなどに発砲するか試験します。
発砲試験のために、アラームに設定している内容を変更するのは、試験内容にはならないことに注意です。
アラームの内容にもよりますが、アラームの数が多いとその分通知が飛ぶため、本来確認すべき内容が分からなくなう可能性があるため、アラーム名を直接指定する形にしています。
スクリプト
test_alerm.sh
#!/bin/sh
cd `dirname $0`
test_alerm () {
ALERM_NAME=$1
echo "test alerm: ${ALERM_NAME}"
aws cloudwatch set-alarm-state \
--alarm-name ${ALERM_NAME} \
--state-value ALARM \
--state-reason '【テストでやんす!!!!】'
}
test_alerm [アラーム名]