Reputation: 79507
How can I modify an existing AWS alarm without figuring out all the parameters? Say if I just want to change a single property.
I tried getting its properties with aws cloudwatch describe-alarms --alarm-names my-alarm
, then modifying the json, and passing it with:
aws cloudwatch put-metric-alarm --alarm-name my-alarm --cli-input-json '<minified json>'
But I'm getting errors:
Parameter validation failed:
Missing required parameter in input: "MetricName"
Missing required parameter in input: "Namespace"
Missing required parameter in input: "Period"
...
I saw Modify Existing alarms AWS, but it uses the AWS SDK with C#, I'm looking for a CLI solution.
Upvotes: 4
Views: 3841
Reputation: 1
As a partial workaround, you can see the entire source of a Cloudwatch alarm in the console:
You'll have the option to see all its parameters in Cloudformation Json/YAML or AWS Cli format...takes just a few moments to create a script you can modify and apply from there.
Upvotes: 0
Reputation: 1425
When you update an existing alarm through cli, its state is left unchanged, but the update completely overwrites the previous configuration of the alarm.
This is clearly mentioned at: https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/put-metric-alarm.html
You need to explicitly mention all the parameters as it will override the previous parameters.
Upvotes: -1
Reputation: 269490
From put-metric-alarm — AWS CLI Command Reference:
When you update an existing alarm, its state is left unchanged, but the update completely overwrites the previous configuration of the alarm.
Therefore, it seems that you will need to specify all the parameters, rather than just the parameter you wish to modify.
Upvotes: 4