File tree Expand file tree Collapse file tree
infrastructure/stacks/api-layer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ resource "aws_wafv2_web_acl" "api_gateway" {
105105
106106 statement {
107107 rate_based_statement {
108- limit = 2000 # Requests per 5-minute period per IP
108+ limit = 300000 # 1000 TPS - we should tie this to other rate limits
109109 aggregate_key_type = " IP"
110110 }
111111 }
Original file line number Diff line number Diff line change @@ -98,17 +98,20 @@ resource "aws_cloudwatch_metric_alarm" "waf_bad_inputs_blocks" {
9898}
9999
100100# Alarm for rate limit violations (overall)
101+ # Rate limit is set to 300,000 req/5min (1000 TPS headroom over 500 TPS peak).
102+ # Any block at this threshold is a serious incident - a single IP would need to exceed
103+ # 300k requests in 5 minutes, which indicates a runaway or compromised proxy.
101104resource "aws_cloudwatch_metric_alarm" "waf_rate_limit_blocks" {
102105 count = local. waf_enabled ? 1 : 0
103106 alarm_name = " WAF-RateLimit-Blocks-${ local . workspace } "
104- alarm_description = " Alerts when requests are rate-limited (potential DDoS) "
107+ alarm_description = " Alerts when requests are rate-limited - at 300k/5min limit this indicates a runaway or compromised proxy "
105108 comparison_operator = " GreaterThanThreshold"
106- evaluation_periods = 2
109+ evaluation_periods = 1
107110 metric_name = " BlockedRequests"
108111 namespace = " AWS/WAFV2"
109112 period = 300
110113 statistic = " Sum"
111- threshold = 50 # Alert after 50 rate-limited requests
114+ threshold = 1 # Any block at this limit is a serious incident
112115 treat_missing_data = " notBreaching"
113116
114117 dimensions = {
@@ -174,7 +177,7 @@ resource "aws_cloudwatch_metric_alarm" "waf_all_requests_high" {
174177 namespace = " AWS/WAFV2"
175178 period = 300
176179 statistic = " Sum"
177- threshold = 10000 # Adjust based on expected traffic
180+ threshold = 300000 # 2x peak (500 TPS = 150k/5min); alert above 300k/5min
178181 treat_missing_data = " notBreaching"
179182
180183 dimensions = {
You can’t perform that action at this time.
0 commit comments