NEW: monitor health events with eventbridge

Signed-off-by: xpk <xpk@headdesk.me>
This commit is contained in:
xpk 2022-12-02 10:59:40 +08:00
parent e627637d21
commit d9cad6b7a3
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
4 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,5 @@
# Monitoring module
This module deploys the default cloudwatch metric monitoring
## Notes
Terraform lifecycle ignores tags to speed up terraform subsequent update. Cloudwatch alarm tags cannot be read on aws console anyway.

View File

@ -0,0 +1,22 @@
resource "aws_cloudwatch_event_rule" "EventRule" {
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."
is_enabled = var.actions-enabled
event_pattern = <<PATTERN
{
"detail-type": [
"AWS Health Event"
],
"source": [
"aws.health"
]
}
PATTERN
tags = var.default-tags
}
resource "aws_cloudwatch_event_target" "TargetForEventRule" {
rule = aws_cloudwatch_event_rule.EventRule.name
target_id = "rackspace-standard-sns"
arn = var.sns-targets.alarm-actions-standard
}

View File

@ -0,0 +1,9 @@
terraform {
required_version = "~> 1.3.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.36.1"
}
}
}

View File

@ -0,0 +1,5 @@
variable cw-alarm-prefix {}
variable actions-enabled {}
variable sns-targets {}
variable default-tags {}