Skip to content

Commit b5ef8ba

Browse files
feat: enable optionally disabling the eks/rds alerts
1 parent dc147d4 commit b5ef8ba

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

eventbridge.tf

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,47 @@
11
# EventBridge Rule (RDS Extended Support Billing)
22
resource "aws_cloudwatch_event_rule" "rds_extended_support_billing" {
3+
count = var.enable_aws_extended_support_alerts ? 1 : 0
34
name = "rds-extended-support-billing-notification"
45
description = "Captures AWS Billing notifications for RDS Extended Support"
56

67
event_pattern = jsonencode({
78
"source" : ["aws.health"],
9+
"detail-type" : ["AWS Health Event"],
810
"detail" : {
911
"eventTypeCode" : ["AWS_BILLING_NOTIFICATION"],
1012
"eventDescription" : [{
11-
"latestDescription" : [{
12-
"wildcard" : ["*RDS Extended Support*"]
13-
}]
13+
"wildcard" : "*RDS Extended Support*"
1414
}]
1515
}
1616
})
1717
}
1818

1919
resource "aws_cloudwatch_event_target" "rds_extended_support_billing" {
20-
rule = aws_cloudwatch_event_rule.rds_extended_support_billing.name
21-
arn = local.sns_topic_arn
20+
count = var.enable_aws_extended_support_alerts ? 1 : 0
21+
rule = aws_cloudwatch_event_rule.rds_extended_support_billing[0].name
22+
arn = local.sns_topic_arn
2223
}
2324

2425
# EventBridge Rule (EKS Extended Support Billing)
2526
resource "aws_cloudwatch_event_rule" "eks_extended_support_billing" {
26-
name = "rds-extended-support-billing-notification"
27+
count = var.enable_aws_extended_support_alerts ? 1 : 0
28+
name = "eks-extended-support-billing-notification"
2729
description = "Captures AWS Billing notifications for EKS Extended Support"
2830

2931
event_pattern = jsonencode({
3032
"source" : ["aws.health"],
33+
"detail-type" : ["AWS Health Event"],
3134
"detail" : {
3235
"eventTypeCode" : ["AWS_BILLING_NOTIFICATION"],
3336
"eventDescription" : [{
34-
"latestDescription" : [{
35-
"wildcard" : ["*EKS Extended Support*"]
36-
}]
37+
"wildcard" : "*EKS Extended Support*"
3738
}]
3839
}
3940
})
4041
}
4142

4243
resource "aws_cloudwatch_event_target" "eks_extended_support_billing" {
43-
rule = aws_cloudwatch_event_rule.rds_extended_support_billing.name
44-
arn = local.sns_topic_arn
44+
count = var.enable_aws_extended_support_alerts ? 1 : 0
45+
rule = aws_cloudwatch_event_rule.rds_extended_support_billing[0].name
46+
arn = local.sns_topic_arn
4547
}

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ variable "enable_aws_config_changes" {
8686
default = true
8787
}
8888

89+
variable "enable_aws_extended_support_alerts" {
90+
description = "The boolean flag whether the eventbridge rules for extended support (EKS/RDS) billing alerts are enabled or not."
91+
type = bool
92+
default = true
93+
}
94+
8995
variable "enable_security_group_changes" {
9096
description = "The boolean flag whether the security_group_changes alarm is enabled or not."
9197
type = bool

0 commit comments

Comments
 (0)