I am trying to setup snooze option for all alarms in my AWS account. To accomplish this I have tried the below terraform code. I kept my account id as dummy value 12345678.
resource "aws_cloudwatch_event_rule" "snooze_alarms_rule" {
name = "snooze_alarms_rule"
description = "Snooze alarms every Sunday from 12:30 PM to 6:30 PM CST"
schedule_expression = "cron(30 18 ? * SUN *)" # 6:30 PM CST is 12:30 AM UTC, so we use that timezone
}
resource "aws_cloudwatch_event_target" "snooze_alarms_target" {
rule = aws_cloudwatch_event_rule.snooze_alarms_rule.name
arn = "arn:aws:automate:${var.region}:12345678:snooze:action/SetAlarmState"
target_id = "snooze_alarms_target" #"arn:aws:sns:${var.region}:12345678:snooze"
input = jsonencode({
"Action": "Snooze",
"StateValue": "ALARM",
"Description": "Snoozing all alarms for maintenance",
"Duration": 21600 # 6 hours in seconds
})
}
But it is giving below error.
Error: creating EventBridge Target
(snooze_alarms_rule-snooze_alarms_target): ValidationException:
automate is not a supported service for a target. │ status code:
400, request id: 56d52814-fc5f-449b-91f5-70f14a0073cf │ │ with
aws_cloudwatch_event_target.snooze_alarms_target, │ on snooze.tf
line 7, in resource "aws_cloudwatch_event_target"
"snooze_alarms_target": │ 7: resource "aws_cloudwatch_event_target"
"snooze_alarms_target" {
I would appreciate any help offered.