2022-12-02 10:59:40 +08:00
resource " aws_cloudwatch_event_rule " " EventRule " {
2024-01-13 00:25:30 +08:00
name = " ${ var . cw - alarm - prefix } -health-events "
description = " A CloudWatch Event Rule that triggers on changes in the status of AWS Personal Health Dashboard (AWS Health) and forwards the events to an SNS topic. "
state = var . actions - enabled
2022-12-02 10:59:40 +08:00
event_pattern = < < PATTERN
{
2024-01-13 00:25:30 +08:00
" detail " : {
" service " : [ " DIRECTCONNECT " , " VPN " , " LAMBDA " , " EC2 " , " RDS " ]
} ,
2022-12-02 10:59:40 +08:00
" detail-type " : [
" AWS Health Event "
] ,
" source " : [
" aws.health "
]
}
PATTERN
2022-12-06 14:35:13 +08:00
lifecycle {
2023-05-23 13:10:16 +08:00
ignore_changes = [ tags [ " LastModified " ] ]
2022-12-06 14:35:13 +08:00
}
2022-12-02 10:59:40 +08:00
}
resource " aws_cloudwatch_event_target " " TargetForEventRule " {
2024-01-13 00:25:30 +08:00
rule = aws_cloudwatch_event_rule . EventRule . name
# target_id = "health-event-notification-sns"
arn = var . settings . healthEvents . action
input_transformer {
input_paths = {
" account " : " $ .account " ,
" endTime " : " $ .detail.endTime " ,
" message " : " $ .detail.eventDescription[0].latestDescription " ,
" resources " : " $ .resources " ,
" service " : " $ .detail.service " ,
" startTime " : " $ .detail.startTime "
}
input_template = < < EOF
" A maintenance has been scheduled for <service> on AWS account <account>. "
" Resources: <resources> "
" Start time: <startTime> "
" End time: <endTime> "
" Detail: <message> "
EOF
}
2023-01-05 23:35:31 +08:00
}