Repository navigation
fix(infra): WAFv2 rejects § in a web ACL description, so prod has no WAF - #913
Merged
Merged
Conversation
#911's `apply (prod)` failed on the last two resources. Everything before them applied — the certificate (ISSUED, both domains SUCCESS), the ALB, both listeners, the www redirect rule, and both Cloudflare records — so `dupezero.com` resolves today with NO web ACL in front of it. WAFv2 validates `description` against ^[\w+=:#@/\-,\.][\w+=:#@/\-,\.\s]+[\w+=:#@/\-,\.]$ which admits neither the `§` this repository uses everywhere nor the brackets that usually accompany it. `CreateWebACL` returns a 400 `ValidationException` quoting the regex and naming nothing else. The constraint is invisible to both earlier tiers: `terraform validate` does not know the provider's server-side rules, and `plan` does not submit the string. So the first thing that can catch it is the apply — in the one environment where a half-finished apply matters. The comment now states the rule at the field, with the regex, because every other description in this file reaches for `§` and the next one added would reintroduce it. Verified the fix against WAF's own pattern, with the old value as a control: the new description matches, the old one does not. No ticket: this is a defect in #555's change rather than new scope, and #555 is closed by the pull request that introduced it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
terraform plan
prod — 2 to add, 0 to changedata.aws_rds_engine_version.aurora_pg: Reading...
data.aws_iam_policy_document.pod_trust: Reading...
data.aws_iam_policy_document.eso_trust: Reading...
module.network.data.aws_region.current: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Reading...
module.network.data.aws_availability_zones.available: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Read complete after 0s [id=2851119427]
module.network.data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.eso_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.pod_trust: Read complete after 0s [id=819195744]
data.aws_caller_identity.current: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Reading...
data.aws_iam_policy_document.efs_csi_trust: Reading...
data.aws_iam_policy_document.efs_csi_trust: Read complete after 0s [id=819195744]
module.eks.data.aws_iam_policy_document.cluster_trust: Read complete after 0s [id=1029077455]
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
module.lake.data.aws_iam_policy_document.lake_tls_only: Reading...
data.aws_iam_policy_document.eso: Reading...
data.aws_iam_policy_document.eso: Read complete after 0s [id=2178872705]
module.lake.data.aws_iam_policy_document.lake_tls_only: Read complete after 0s [id=3960055703]
data.aws_iam_policy_document.lake_access: Reading...
data.aws_iam_policy_document.lake_access: Read complete after 0s [id=3734071059]
module.network.data.aws_availability_zones.available: Read complete after 0s [id=us-east-2]
data.aws_rds_engine_version.aurora_pg: Read complete after 0s [id=17.9]
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_wafv2_web_acl.edge will be created
+ resource "aws_wafv2_web_acl" "edge" {
+ application_integration_url = (known after apply)
+ arn = (known after apply)
+ capacity = (known after apply)
+ description = "Rate limits on the three unauthenticated write paths - see infrastructure.md 4.1"
+ id = (known after apply)
+ lock_token = (known after apply)
+ name = "er-prod-edge"
+ name_prefix = (known after apply)
+ region = "us-east-2"
+ scope = "REGIONAL"
+ tags = {
+ "Name" = "er-prod-edge"
}
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Name" = "er-prod-edge"
+ "Project" = "entity-resolution"
}
+ default_action {
+ allow {
}
}
+ rule {
+ name = "rate-invites"
+ priority = 30
+ action {
+ block {
}
}
+ statement {
+ rate_based_statement {
+ aggregate_key_type = "IP"
+ evaluation_window_sec = 300
+ limit = 50
+ scope_down_statement {
+ byte_match_statement {
+ positional_constraint = "STARTS_WITH"
+ search_string = "/api/invites"
+ field_to_match {
+ uri_path {}
}
+ text_transformation {
+ priority = 0
+ type = "LOWERCASE"
}
}
}
}
}
+ visibility_config {
+ cloudwatch_metrics_enabled = true
+ metric_name = "er-prod-rate-invites"
+ sampled_requests_enabled = true
}
}
+ rule {
+ name = "rate-login"
+ priority = 10
+ action {
+ block {
}
}
+ statement {
+ rate_based_statement {
+ aggregate_key_type = "IP"
+ evaluation_window_sec = 300
+ limit = 100
+ scope_down_statement {
+ byte_match_statement {
+ positional_constraint = "STARTS_WITH"
+ search_string = "/api/auth/login"
+ field_to_match {
+ uri_path {}
}
+ text_transformation {
+ priority = 0
+ type = "LOWERCASE"
}
}
}
}
}
+ visibility_config {
+ cloudwatch_metrics_enabled = true
+ metric_name = "er-prod-rate-login"
+ sampled_requests_enabled = true
}
}
+ rule {
+ name = "rate-password-reset"
+ priority = 20
+ action {
+ block {
}
}
+ statement {
+ rate_based_statement {
+ aggregate_key_type = "IP"
+ evaluation_window_sec = 300
+ limit = 20
+ scope_down_statement {
+ byte_match_statement {
+ positional_constraint = "STARTS_WITH"
+ search_string = "/api/auth/password-reset"
+ field_to_match {
+ uri_path {}
}
+ text_transformation {
+ priority = 0
+ type = "LOWERCASE"
}
}
}
}
}
+ visibility_config {
+ cloudwatch_metrics_enabled = true
+ metric_name = "er-prod-rate-password-reset"
+ sampled_requests_enabled = true
}
}
+ visibility_config {
+ cloudwatch_metrics_enabled = true
+ metric_name = "er-prod-edge"
+ sampled_requests_enabled = true
}
}
# aws_wafv2_web_acl_association.edge will be created
+ resource "aws_wafv2_web_acl_association" "edge" {
+ id = (known after apply)
+ region = "us-east-2"
+ resource_arn = "arn:aws:elasticloadbalancing:us-east-2:797781631727:loadbalancer/app/er-prod-edge/6505998c524f769a"
+ web_acl_arn = (known after apply)
}
Plan: 2 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ edge_web_acl_arn = (known after apply)
|
This was referenced Nov 8, 2026
Closed
Merged
Closed
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.
What
One string. WAFv2 rejects
§and parentheses in a web ACLdescription, so #911's web ACL and its ALB association were the only two resources that failed to apply.Why
Prod is currently serving with no WAF. #911's
apply (prod)got through the certificate, the ALB, both listeners, thewwwredirect rule and both Cloudflare records, then failed onCreateWebACL:That pattern admits neither the
§this repo uses throughout nor the brackets that usually go with it. Neither earlier tier can catch it:validatedoes not know the provider's server-side rules andplannever submits the string, so the apply is the first thing that sees it — in the one environment where a half-finished apply matters.Proof
Checked the new value against WAF's own regex, with the old value as a control, so the check is known to discriminate rather than just pass:
bash scripts/ci/tf-validate-all.sh— 5/5Success!.terraform fmt -check -recursiveclean.Risk & rollback
Risk: low, and it reduces live risk — it creates the two resources that were meant to exist. The plan should be
2 to add, 0 to change, 0 to destroy. Rollback:git revert, which returns prod to the current unprotected state, so the revert is worse than the change.Post-merge ledger
Closed by: agent · session
a7f03c6d-206a-4ae3-a5c3-1c2f74052399onMac· 2026-11-08T21:20:00Zmainis green with this change on it —mainhead7cfeafc8has this commit as an ancestor.rustrun 42523297782 success, 23 jobs, zero failures;infra,frontend,devcontainer,deployon the same SHA also success.images—n/a — one string in a Terraform file; no image inputs changed.deploy—n/a — nothing to deploy.infrais green onmain's head with all three applies success, run 42523297838. This change's ownapply (prod)failed, and not for its own reason: infra(core): declare the R2 sccache bucket and its lifecycle rule #912 had setCLOUDFLARE_API_TOKENas a job-levelenv:, which overrides$GITHUB_ENVand shadowed the prod token — Cloudflare9106. Fixed in fix(ci): a job-level env: shadows $GITHUB_ENV, so the prod Cloudflare token never applied #919, which is what finally applied these two resources.n/a —no-ticket.This reconciles a defect in Prod edge #555's change rather than closing a card; Prod edge #555 was alreadyDonefrom feat(infra): prod edge — internet-facing ALB behind AWS WAF, DNS in Terraform #911.env:-precedence defect this exposed is fix(ci): a job-level env: shadows $GITHUB_ENV, so the prod Cloudflare token never applied #919, merged.edge.tfwith the pattern inline, which is where the next person adding a description will read it. Not a memory: it is a property of one resource type in one file, and the file is the right place for it.Specific to this change
apply (prod)created the web ACL and the association — verified from AWS, not from a conclusion:aws wafv2 list-web-acls --scope REGIONAL→er-prod-edge 8aff260c-3895-4773-baac-0db11a70e24e, andget-web-acl-for-resourceon the ALB ARN →er-prod-edge. The association is the half that makes it real; an unassociated ACL would list identically.aws wafv2 get-web-acl:rate-login100/300s/api/auth/login;rate-password-reset20/300s/api/auth/password-reset;rate-invites50/300s/api/invites. The API returnsSearchStringbase64-encoded, decoded above — reading it raw would look like a wrong path./api/auth/login→ 60× 403, with 5 GETs to/from the same address at the same moment → 5× 503. The control is what makes it meaningful. Worth recording that the FIRST flood of 130 returned zero blocks: a rate rule needs a warm-up, andget-rate-based-statement-managed-keysshowed the address already tracked, which is how lag was distinguished from a non-matching rule. Memory:waf-rate-rule-needs-warmup.Context — plan, discoveries, measurements, files
Discoveries
§appears in nearly every comment and description ininfra/terraform/, and AWS accepts it in EC2 security-group descriptions (those applied fine in the same run) but not in WAFv2's. So this is not a rule that generalises across the file — which is exactly why the fix carries the regex in a comment at the field rather than a note elsewhere.Measurements
Files
infra/terraform/envs/prod/edge.tf— the web ACL description, plus the comment stating the constraint