简体   繁体   中英

Modify existing AWS alarm with AWS-CLI

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM