Repository navigation
feat(infra): prod WAF managed rule groups — IP reputation blocks, body-inspecting groups count - #949
Merged
Merged
Conversation
…y-inspecting groups count
Contributor
terraform plan
Warning This plan DESTROYS resources in: core. Merging applies it unattended. core — 0 to add, 0 to change, 2 to DESTROYdata.aws_iam_policy_document.ci_tf_plan_state: Reading...
module.identity_center.data.aws_ssoadmin_instances.this: Reading...
data.aws_iam_policy_document.ci_tf_apply_no_prod_state: Reading...
data.aws_iam_policy_document.ci_tf_apply_no_prod_state: Read complete after 0s [id=2395007408]
data.aws_iam_policy_document.ci_tf_plan_state: Read complete after 0s [id=2883378100]
data.aws_iam_policy_document.obs_pod_trust: Reading...
data.aws_iam_policy_document.obs_pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.ci_tf_drift_refresh: Reading...
data.aws_caller_identity.current: Reading...
data.aws_iam_policy_document.ci_tf_drift_refresh: Read complete after 0s [id=2350222434]
data.aws_iam_policy_document.sccache_read: Reading...
module.github_oidc.data.aws_iam_policy_document.trust: Reading...
data.aws_iam_policy_document.sccache_read: Read complete after 0s [id=2701062528]
module.github_oidc.data.aws_iam_policy_document.trust: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.sccache_write: Reading...
data.aws_iam_policy_document.sccache_write: Read complete after 0s [id=786296009]
data.aws_iam_policy_document.cur_delivery: Reading...
data.aws_iam_policy_document.cur_delivery: Read complete after 0s [id=2207400467]
data.aws_iam_policy_document.audit_bucket: Reading...
data.aws_iam_policy_document.sccache_trust_write: Reading...
data.aws_iam_policy_document.ci_tf_drift_trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_trust: Reading...
data.aws_iam_policy_document.sccache_trust_write: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.sccache_trust_read: Reading...
data.aws_iam_policy_document.ci_tf_apply_trust: Read complete after 0s [id=2538345208]
data.aws_iam_policy_document.ci_tf_drift_trust: Read complete after 0s [id=2357770959]
data.aws_iam_policy_document.config_bucket: Reading...
data.aws_iam_policy_document.audit_bucket: Read complete after 0s [id=3031279952]
data.aws_iam_policy_document.ci_tf_plan_trust: Reading...
data.aws_iam_policy_document.ci_tf_plan_trust: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.config_bucket: Read complete after 0s [id=4067691321]
data.aws_iam_policy_document.sccache_trust_read: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.openobserve: Reading...
data.aws_iam_policy_document.openobserve: Read complete after 0s [id=2662704728]
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
module.github_oidc.data.aws_iam_policy_document.push: Reading...
module.github_oidc.data.aws_iam_policy_document.push: Read complete after 0s [id=2177873069]
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Read complete after 0s [id=3513372776]
module.identity_center.data.aws_ssoadmin_instances.this: Read complete after 0s [id=us-east-2]
module.identity_center.data.aws_identitystore_user.admin: Reading...
module.identity_center.data.aws_identitystore_user.admin: Read complete after 1s [id=b17b2500-e0b1-7046-405b-23c088cf392b]
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
- destroy
Terraform will perform the following actions:
# cloudflare_r2_bucket.sccache[0] will be destroyed
# (because index [0] is out of range for count)
- resource "cloudflare_r2_bucket" "sccache" {
- account_id = "9eefbe6bc92d11b2bb4e962494765a4c" -> null
- creation_date = "2026-11-08T20:59:18.644Z" -> null
- id = "er-ci-sccache" -> null
- jurisdiction = "default" -> null
- location = "ENAM" -> null
- name = "er-ci-sccache" -> null
- storage_class = "Standard" -> null
}
# cloudflare_r2_bucket_lifecycle.sccache[0] will be destroyed
# (because index [0] is out of range for count)
- resource "cloudflare_r2_bucket_lifecycle" "sccache" {
- account_id = "9eefbe6bc92d11b2bb4e962494765a4c" -> null
- bucket_name = "er-ci-sccache" -> null
- jurisdiction = "default" -> null
- rules = [
- {
- abort_multipart_uploads_transition = {
- condition = {
- max_age = 86400 -> null
- type = "Age" -> null
} -> null
} -> null
- conditions = {
# (1 unchanged attribute hidden)
} -> null
- delete_objects_transition = {
- condition = {
- max_age = 1209600 -> null
- type = "Age" -> null
} -> null
} -> null
- enabled = true -> null
- id = "expire-cache-objects" -> null
},
] -> null
}
Plan: 0 to add, 0 to change, 2 to destroy.
Changes to Outputs:
- r2_sccache_bucket = "er-ci-sccache" -> null
- r2_sccache_endpoint = "https://9eefbe6bc92d11b2bb4e962494765a4c.r2.cloudflarestorage.com" -> null
Warning: Resource Destruction Considerations
with cloudflare_r2_bucket_lifecycle.sccache[0],
on r2.tf line 96, in resource "cloudflare_r2_bucket_lifecycle" "sccache":
96: resource "cloudflare_r2_bucket_lifecycle" "sccache" {
Applying this resource destruction will remove the resource from the
Terraform state but will not change it in the API. If you would like to
destroy or reset this resource in the API, refer to the documentation for how
to do it manually.
prod — 0 to add, 1 to changedata.aws_iam_policy_document.efs_csi_trust: Reading...
module.network.data.aws_availability_zones.available: Reading...
module.ses.data.aws_region.current: Reading...
data.aws_iam_openid_connect_provider.github: Reading...
data.aws_iam_policy_document.efs_csi_trust: Read complete after 0s [id=819195744]
module.ses.data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_caller_identity.current: Reading...
data.aws_iam_policy_document.eso_trust: Reading...
data.aws_iam_policy_document.eso_trust: Read complete after 0s [id=819195744]
module.network.data.aws_region.current: Reading...
data.aws_rds_engine_version.aurora_pg: Reading...
module.network.data.aws_region.current: Read complete after 0s [id=us-east-2]
module.eks.data.aws_iam_policy_document.cluster_trust: Reading...
data.aws_iam_policy_document.pod_trust: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Read complete after 0s [id=1029077455]
data.aws_iam_policy_document.pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.otel_collector: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Read complete after 0s [id=2851119427]
data.aws_iam_policy_document.otel_collector: Read complete after 0s [id=1193716550]
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
module.lake.data.aws_iam_policy_document.lake_tls_only: Reading...
module.lake.data.aws_iam_policy_document.lake_tls_only: Read complete after 1s [id=3960055703]
data.aws_iam_policy_document.fluent_bit: Reading...
data.aws_iam_policy_document.fluent_bit: Read complete after 0s [id=2978074842]
data.aws_iam_policy_document.eso: Reading...
data.aws_iam_policy_document.eso: Read complete after 0s [id=2178872705]
data.aws_iam_policy_document.lake_access: Reading...
data.aws_iam_policy_document.lake_access: Read complete after 0s [id=3734071059]
data.aws_iam_openid_connect_provider.github: Read complete after 1s [id=arn:aws:iam::797781631727:oidc-provider/token.actions.githubusercontent.com]
module.ses.data.aws_iam_policy_document.send: Reading...
module.ses.data.aws_iam_policy_document.send: Read complete after 0s [id=3767633194]
data.aws_iam_policy_document.ci_deploy_prod_trust: Reading...
data.aws_iam_policy_document.ci_deploy_prod_trust: Read complete after 0s [id=4060172364]
data.aws_rds_engine_version.aurora_pg: Read complete after 1s [id=17.9]
module.network.data.aws_availability_zones.available: Read complete after 1s [id=us-east-2]
data.aws_iam_policy_document.ci_deploy_prod: Reading...
data.aws_iam_policy_document.ci_deploy_prod: Read complete after 0s [id=3634844169]
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# aws_wafv2_web_acl.edge will be updated in-place
~ resource "aws_wafv2_web_acl" "edge" {
id = "8aff260c-3895-4773-baac-0db11a70e24e"
name = "er-prod-edge"
tags = {
"Name" = "er-prod-edge"
}
# (10 unchanged attributes hidden)
+ rule {
+ name = "managed-common-ruleset"
+ priority = 40
+ override_action {
+ count {}
}
+ statement {
+ managed_rule_group_statement {
+ name = "AWSManagedRulesCommonRuleSet"
+ vendor_name = "AWS"
# (1 unchanged attribute hidden)
}
}
+ visibility_config {
+ cloudwatch_metrics_enabled = true
+ metric_name = "er-prod-edge-common-ruleset"
+ sampled_requests_enabled = true
}
}
+ rule {
+ name = "managed-ip-reputation"
+ priority = 1
+ override_action {
+ none {}
}
+ statement {
+ managed_rule_group_statement {
+ name = "AWSManagedRulesAmazonIpReputationList"
+ vendor_name = "AWS"
# (1 unchanged attribute hidden)
}
}
+ visibility_config {
+ cloudwatch_metrics_enabled = true
+ metric_name = "er-prod-edge-ip-reputation"
+ sampled_requests_enabled = true
}
}
+ rule {
+ name = "managed-known-bad-inputs"
+ priority = 50
+ override_action {
+ count {}
}
+ statement {
+ managed_rule_group_statement {
+ name = "AWSManagedRulesKnownBadInputsRuleSet"
+ vendor_name = "AWS"
# (1 unchanged attribute hidden)
}
}
+ visibility_config {
+ cloudwatch_metrics_enabled = true
+ metric_name = "er-prod-edge-known-bad-inputs"
+ sampled_requests_enabled = true
}
}
# (5 unchanged blocks hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
|
athvin
marked this pull request as ready for review
November 9, 2026 01:23
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #921
What
Three managed rule groups on
er-prod-edge:AWSManagedRulesAmazonIpReputationListin BLOCK at priority 1 (ahead of the rate rules), andAWSManagedRulesCommonRuleSet+AWSManagedRulesKnownBadInputsRuleSetin COUNT at priorities 40/50 (after the rate rules). The header comment's "no managed groups yet" paragraph becomes the decision record for what is there now, including the 931/1500 WCU capacity math.Why
The reputation list inspects no bodies and its false-positive rate is the lowest of the managed groups; the scanners that found the hostname within minutes of the DNS record are its population, and it sheds them before they spend the rate rules' counts. The body-inspecting groups would reject legitimate traffic blind — this API carries SQL-shaped blocking configuration and arbitrary customer column names — so they count until a week of
CountedRequestsper rule says what to exclude. Counting AFTER the rate rules makes the counted population exactly the requests that would reach the app.Proof
terraform validateon envs/prod — Success (1.11.4);terraform fmtclean. Nodescriptiontouched: the WAFv2 character restriction (the 400-at-apply trap from #911) applies to the ACL's description only, which is unchanged; rule names and metric names stay inside the existing[a-z0-9-]style.Risk & rollback
Risk: the reputation list now BLOCKS — a false positive is a 403 at the edge with no app log, but that list's FP rate is the reason it was chosen to block, and
BlockedRequestson its metric plus sampled requests show anything it catches. The two count groups change nothing about request handling. Rollback:git revert <merge-sha>.Post-merge ledger
Closed by: agent · codex session on
Athvins-MacBook-Pro· 2026-11-09T01:45:00Zmainis green with this change on it — merge6720c1ae; rust run 42545317274 success, frontend 42545317310 success, devcontainer 42545317319 success, infra 42545317303 success.imagescorrectly never ran — a terraform-only merge matches none of images.yml's push paths; no images run exists for6720c1ae.deployn/a by the same mechanism — deploy is reachable only through images'workflow_run.Closes; the time-gated tuning half moved to WAF tuning: a week of CountedRequests, exclusions, then flip the two body-inspecting groups to BLOCK #951 rather than vanishing with the close.Specific to this change
aws wafv2 get-web-acloner-prod-edgereads back exactly the intended rule set: priority 1managed-ip-reputationoverride None (the group's own block), 10/20/30 the three rate rules with Block untouched, 40managed-common-rulesetand 50managed-known-bad-inputsoverride Count. No known-bad source was handy for a live block probe; the rules' CloudWatch metrics (er-prod-edge-ip-reputation,-common-ruleset,-known-bad-inputs) are enabled for the week of counting WAF tuning: a week of CountedRequests, exclusions, then flip the two body-inspecting groups to BLOCK #951 reads.Context — plan, discoveries, measurements, files
Plan
Discoveries
description; none of the new blocks carries one.Measurements
AllowedRequestsin one 5-minute period within minutes of the DNS record existing.terraform -chdir=infra/terraform/envs/prod validate→ Success.Files
infra/terraform/envs/prod/edge.tf— three rule blocks + the rewritten WAF header comment.