@@ -129,14 +129,14 @@ resource "aws_cloudwatch_metric_alarm" "waf_rate_limit_blocks" {
129129 )
130130}
131131
132- # Alarm for non-UK rate limit violations
132+ # Alarm for blocked non-UK requests
133133resource "aws_cloudwatch_metric_alarm" "waf_non_uk_counted" {
134134 count = local. waf_enabled ? 1 : 0
135- alarm_name = " WAF-NonUK-CountedRequests -${ local . workspace } "
136- alarm_description = " Alerts when non-UK requests are observed (COUNT mode) by geo rule"
135+ alarm_name = " WAF-NonUK-BlockedRequests -${ local . workspace } "
136+ alarm_description = " Alerts when non-UK requests are blocked by geo rule - may indicate stolen mTLS cert use from outside UK "
137137 comparison_operator = " GreaterThanThreshold"
138138 evaluation_periods = 2
139- metric_name = " CountedRequests "
139+ metric_name = " BlockedRequests "
140140 namespace = " AWS/WAFV2"
141141 period = 300
142142 statistic = " Sum"
@@ -145,7 +145,7 @@ resource "aws_cloudwatch_metric_alarm" "waf_non_uk_counted" {
145145
146146 dimensions = {
147147 Region = var.default_aws_region
148- Rule = " MonitorNonUK "
148+ Rule = " BlockNonUK "
149149 WebACL = aws_wafv2_web_acl.api_gateway[0 ].name
150150 }
151151
@@ -154,8 +154,8 @@ resource "aws_cloudwatch_metric_alarm" "waf_non_uk_counted" {
154154 tags = merge (
155155 local. tags ,
156156 {
157- Name = " WAF-NonUK-CountedRequests "
158- Severity = " medium "
157+ Name = " WAF-NonUK-BlockedRequests "
158+ Severity = " high "
159159 Environment = var.environment
160160 }
161161 )
@@ -192,19 +192,21 @@ resource "aws_cloudwatch_metric_alarm" "waf_all_requests_high" {
192192 )
193193}
194194
195- # Alarm for monitoring counted requests (during initial count mode)
196- # This helps identify if rules would block legitimate traffic
195+ # Alarm for counted requests (NoUserAgent_Header override)
196+ # The CRS NoUserAgent_Header sub-rule is kept in COUNT to allow the API proxy healthcheck.
197+ # This alarm alerts if count spikes unexpectedly, which could indicate rule misconfiguration
198+ # or unexpected traffic patterns hitting that override.
197199resource "aws_cloudwatch_metric_alarm" "waf_counted_requests_monitoring" {
198200 count = local. waf_enabled ? 1 : 0
199201 alarm_name = " WAF-CountedRequests-Monitoring-${ local . workspace } "
200- alarm_description = " Monitors requests that would be blocked if rules were active (COUNT mode )"
202+ alarm_description = " Monitors counted requests - expected to be low volume (healthcheck NoUserAgent_Header override only )"
201203 comparison_operator = " GreaterThanThreshold"
202204 evaluation_periods = 1
203205 metric_name = " CountedRequests"
204206 namespace = " AWS/WAFV2"
205207 period = 300
206208 statistic = " Sum"
207- threshold = 100 # Alert if many requests would be blocked
209+ threshold = 100 # Alert if count spikes beyond normal healthcheck frequency
208210 treat_missing_data = " notBreaching"
209211
210212 dimensions = {
@@ -220,7 +222,7 @@ resource "aws_cloudwatch_metric_alarm" "waf_counted_requests_monitoring" {
220222 Name = " WAF-CountedRequests-Monitoring"
221223 Severity = " low"
222224 Environment = var.environment
223- Purpose = " Initial monitoring during COUNT mode phase "
225+ Purpose = " Monitor NoUserAgent_Header count override for healthcheck proxy "
224226 }
225227 )
226228}
0 commit comments