Testing cloudwatch alarm using AWS CLI

Many of us are using Cloudwatch alarms for triggering some action. It could be an SNS or a lambda function etc. We can use this AWS CLI command to temporarily set cloudwatch alarm state for testing purposes.

We can change the state of the alarm “MyalarmName” to ALARM as follows.

aws cloudwatch set-alarm-state –alarm-name MyalarmName –state-reason “testing alarm” –state-value ALARM

The alarm returns to actual state usually within seconds.