https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/US_AlarmAtThresholdEBS.html
-- 1. コマンド等のインストール
-- 1.1 aws cli version 2 インストール
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws --version
-- 2. SNSトピック作成
aws sns list-topics
aws sns list-subscriptions
aws sns create-topic --name topic01
aws sns subscribe \
--topic-arn arn:aws:sns:ap-northeast-1:999999999999:topic01 \
--protocol email \
--notification-endpoint hoge@example.com
aws sns create-topic --name topic02
aws sns subscribe \
--topic-arn arn:aws:sns:ap-northeast-1:999999999999:topic02 \
--protocol email \
--notification-endpoint hoge@example.net
-- 3. EBSストレージスループットアラームを作成
aws cloudwatch put-metric-alarm \
--alarm-name alarm01 \
--alarm-description "alarm01" \
--metric-name VolumeReadBytes \
--namespace AWS/EBS \
--statistic Average \
--period 300 \
--threshold 100000000 \
--comparison-operator GreaterThanThreshold \
--dimensions Name=VolumeId,Value=vol-11111111111111111 \
--evaluation-periods 3 \
--alarm-actions arn:aws:sns:ap-northeast-1:999999999999:topic01 \
--insufficient-data-actions arn:aws:sns:ap-northeast-1:999999999999:topic02
aws cloudwatch describe-alarms
-- 4. EBSストレージスループットアラームをテスト
aws cloudwatch set-alarm-state \
--alarm-name alarm01 \
--state-reason "OK" \
--state-value OK
aws cloudwatch set-alarm-state \
--alarm-name alarm01 \
--state-reason "ALARM" \
--state-value ALARM
aws cloudwatch set-alarm-state \
--alarm-name alarm01 \
--state-reason "INSUFFICIENT_DATA" \
--state-value INSUFFICIENT_DATA
-- 5. クリーンアップ
-- アラームの削除
aws cloudwatch describe-alarms
aws cloudwatch delete-alarms \
--alarm-names alarm01
-- SNSトピック削除
aws sns unsubscribe --subscription-arn arn:aws:sns:ap-northeast-1:999999999999:topic01:11111111-2222-3333-4444-555555555555
aws sns delete-topic --topic-arn arn:aws:sns:ap-northeast-1:999999999999:topic01
aws sns unsubscribe --subscription-arn arn:aws:sns:ap-northeast-1:999999999999:topic02:11111111-2222-3333-4444-555555555555
aws sns delete-topic --topic-arn arn:aws:sns:ap-northeast-1:999999999999:topic02
aws sns list-topics
aws sns list-subscriptions