Repository navigation
Conversation
…erraform (#555) The §4.1 prod edge. Nothing of it existed anywhere: no ACM certificate in the tree at all, no WAF, no external-dns installed, and the chart's `ingress-web.yaml` written for dev with `scheme: internal` and `enabled: false`. - ACM certificate for the apex plus `www`, DNS-validated through Cloudflare. The apex is not a free choice: `frontend/src/lib/site/routes.ts` hardcodes `CANONICAL_ORIGIN = "https://dupezero.com"` and the marketing pages and the app are the same Next.js app, so one hostname serves `/`, `/login`, `/app` and `/api/*`. `www` redirects to it at the listener rather than serving it, so the canonical origin stays one value. - Internet-facing ALB in the public subnets, TLS 1.2 floor with 1.3 available, port 80 open only to be 301'd. Health check on `/api/healthz` — which works only because that path is in the proxy's PUBLIC_PATHS; any other path answers a session-less request with a 307 and would mark every healthy pod unhealthy. - WAFv2 regional web ACL, allow-by-default, with rate rules on the three unauthenticated WRITE paths §4.1 names. Thresholds differ by what abuse costs: password-reset is tightest because it sends email on an unauthenticated request, spending the domain's sending reputation. No managed rule groups yet, deliberately — CommonRuleSet inspects bodies and this is a JSON API carrying SQL-shaped config and arbitrary customer column names, which is what its SQLi rules match on. - Cloudflare apex and `www` records, DNS-only. DNS-only rather than Cloudflare-proxied, by operator decision: a proxied edge is bypassable unless the ALB security group is pinned to Cloudflare's IP ranges and that list kept fresh, the zone is on the Free plan (verified) which gives one rate-limiting rule against the three needed, and WAF on the listener has no bypass path at all. No external-dns, and so no second Cloudflare token. Terraform owns the load balancer, so it already knows the DNS name and writes the record itself — which removes a controller, the scoped token it would have needed, and the ExternalSecret to project it. Pods join via TargetGroupBinding (#556); it is available on er-prod as `eks.amazonaws.com/v1`, verified against the cluster. Two module outputs were missing and are added rather than worked around: `cluster_security_group_id`, because with `target_type = "ip"` the targets are pod addresses and a pod IP is a secondary address on a node ENI — so ALB→pod traffic is evaluated against the NODE security group, and without that rule the targets health-check unhealthy with no indication why; and `vpc_cidr`. The credential path keeps infra.yml's "no repository secrets" property. The token is read from Secrets Manager by the apply tier using the prod role's own AdministratorAccess, after the §14.2 hop — not from a GitHub secret, because the PLAN role is assumable from any PR branch and a PR can edit the workflow it runs under. The plan tier is given nothing and needs nothing: measured 2026-11-08, a `-refresh=false` plan of a `cloudflare_dns_record` with no credentials in the environment returns `Plan: 1 to add`. The constraint that keeps that true is recorded in edge.tf — no Cloudflare `data` sources in this stack, because a data source IS read at plan time regardless of `-refresh=false`. `CLOUDFLARE_API_TOKEN` in the environment rather than a `TF_VAR_`, matching envs/dev and for the reason stated there: a variable lands in the saved plan file, and the apply tier plans to `tfplan` then applies that file. Closes #555 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
terraform plan
prod — 18 to add, 0 to changemodule.eks.data.aws_iam_policy_document.cluster_trust: Reading...
data.aws_rds_engine_version.aurora_pg: Reading...
module.network.data.aws_availability_zones.available: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Read complete after 0s [id=1029077455]
module.network.data.aws_region.current: Reading...
module.network.data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.efs_csi_trust: Reading...
module.eks.data.aws_iam_policy_document.node_trust: Reading...
data.aws_caller_identity.current: Reading...
data.aws_iam_policy_document.efs_csi_trust: Read complete after 0s [id=819195744]
module.eks.data.aws_iam_policy_document.node_trust: Read complete after 0s [id=2851119427]
data.aws_iam_policy_document.pod_trust: Reading...
data.aws_iam_policy_document.eso_trust: Reading...
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]
module.lake.data.aws_iam_policy_document.lake_tls_only: Reading...
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]
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
data.aws_iam_policy_document.eso: Reading...
data.aws_iam_policy_document.eso: Read complete after 0s [id=2178872705]
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_acm_certificate.edge will be created
+ resource "aws_acm_certificate" "edge" {
+ arn = (known after apply)
+ domain_name = "dupezero.com"
+ domain_validation_options = [
+ {
+ domain_name = "dupezero.com"
+ resource_record_name = (known after apply)
+ resource_record_type = (known after apply)
+ resource_record_value = (known after apply)
},
+ {
+ domain_name = "www.dupezero.com"
+ resource_record_name = (known after apply)
+ resource_record_type = (known after apply)
+ resource_record_value = (known after apply)
},
]
+ id = (known after apply)
+ key_algorithm = (known after apply)
+ not_after = (known after apply)
+ not_before = (known after apply)
+ pending_renewal = (known after apply)
+ private_key_wo = (write-only attribute)
+ region = "us-east-2"
+ renewal_eligibility = (known after apply)
+ renewal_summary = (known after apply)
+ status = (known after apply)
+ subject_alternative_names = [
+ "dupezero.com",
+ "www.dupezero.com",
]
+ tags = {
+ "Name" = "er-prod-edge"
}
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Name" = "er-prod-edge"
+ "Project" = "entity-resolution"
}
+ type = (known after apply)
+ validation_emails = (known after apply)
+ validation_method = "DNS"
+ options (known after apply)
}
# aws_acm_certificate_validation.edge will be created
+ resource "aws_acm_certificate_validation" "edge" {
+ certificate_arn = (known after apply)
+ id = (known after apply)
+ region = "us-east-2"
+ validation_record_fqdns = (known after apply)
+ timeouts {
+ create = "15m"
}
}
# aws_lb.edge will be created
+ resource "aws_lb" "edge" {
+ arn = (known after apply)
+ arn_suffix = (known after apply)
+ client_keep_alive = 3600
+ desync_mitigation_mode = "defensive"
+ dns_name = (known after apply)
+ drop_invalid_header_fields = true
+ enable_deletion_protection = true
+ enable_http2 = true
+ enable_prefix_for_ipv6_source_nat = (known after apply)
+ enable_tls_version_and_cipher_suite_headers = false
+ enable_waf_fail_open = false
+ enable_xff_client_port = false
+ enable_zonal_shift = false
+ enforce_security_group_inbound_rules_on_private_link_traffic = (known after apply)
+ id = (known after apply)
+ idle_timeout = 60
+ internal = false
+ ip_address_type = (known after apply)
+ load_balancer_type = "application"
+ name = "er-prod-edge"
+ name_prefix = (known after apply)
+ preserve_host_header = false
+ region = "us-east-2"
+ secondary_ips_auto_assigned_per_subnet = (known after apply)
+ security_groups = (known after apply)
+ subnets = [
+ "subnet-02b8a601e5e1ee986",
+ "subnet-059bdc493f8e37257",
+ "subnet-0b19390cc3bc63620",
]
+ tags = {
+ "Name" = "er-prod-edge"
}
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Name" = "er-prod-edge"
+ "Project" = "entity-resolution"
}
+ vpc_id = (known after apply)
+ xff_header_processing_mode = "append"
+ zone_id = (known after apply)
+ subnet_mapping (known after apply)
}
# aws_lb_listener.http_redirect will be created
+ resource "aws_lb_listener" "http_redirect" {
+ arn = (known after apply)
+ id = (known after apply)
+ load_balancer_arn = (known after apply)
+ port = 80
+ protocol = "HTTP"
+ region = "us-east-2"
+ routing_http_request_x_amzn_mtls_clientcert_header_name = (known after apply)
+ routing_http_request_x_amzn_mtls_clientcert_issuer_header_name = (known after apply)
+ routing_http_request_x_amzn_mtls_clientcert_leaf_header_name = (known after apply)
+ routing_http_request_x_amzn_mtls_clientcert_serial_number_header_name = (known after apply)
+ routing_http_request_x_amzn_mtls_clientcert_subject_header_name = (known after apply)
+ routing_http_request_x_amzn_mtls_clientcert_validity_header_name = (known after apply)
+ routing_http_request_x_amzn_tls_cipher_suite_header_name = (known after apply)
+ routing_http_request_x_amzn_tls_version_header_name = (known after apply)
+ routing_http_response_access_control_allow_credentials_header_value = (known after apply)
+ routing_http_response_access_control_allow_headers_header_value = (known after apply)
+ routing_http_response_access_control_allow_methods_header_value = (known after apply)
+ routing_http_response_access_control_allow_origin_header_value = (known after apply)
+ routing_http_response_access_control_expose_headers_header_value = (known after apply)
+ routing_http_response_access_control_max_age_header_value = (known after apply)
+ routing_http_response_content_security_policy_header_value = (known after apply)
+ routing_http_response_server_enabled = (known after apply)
+ routing_http_response_strict_transport_security_header_value = (known after apply)
+ routing_http_response_x_content_type_options_header_value = (known after apply)
+ routing_http_response_x_frame_options_header_value = (known after apply)
+ ssl_policy = (known after apply)
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Project" = "entity-resolution"
}
+ tcp_idle_timeout_seconds = (known after apply)
+ default_action {
+ order = (known after apply)
+ type = "redirect"
+ redirect {
+ host = "#{host}"
+ path = "/#{path}"
+ port = "443"
+ protocol = "HTTPS"
+ query = "#{query}"
+ status_code = "HTTP_301"
}
}
+ mutual_authentication (known after apply)
}
# aws_lb_listener.https will be created
+ resource "aws_lb_listener" "https" {
+ arn = (known after apply)
+ certificate_arn = (known after apply)
+ id = (known after apply)
+ load_balancer_arn = (known after apply)
+ port = 443
+ protocol = "HTTPS"
+ region = "us-east-2"
+ routing_http_request_x_amzn_mtls_clientcert_header_name = (known after apply)
+ routing_http_request_x_amzn_mtls_clientcert_issuer_header_name = (known after apply)
+ routing_http_request_x_amzn_mtls_clientcert_leaf_header_name = (known after apply)
+ routing_http_request_x_amzn_mtls_clientcert_serial_number_header_name = (known after apply)
+ routing_http_request_x_amzn_mtls_clientcert_subject_header_name = (known after apply)
+ routing_http_request_x_amzn_mtls_clientcert_validity_header_name = (known after apply)
+ routing_http_request_x_amzn_tls_cipher_suite_header_name = (known after apply)
+ routing_http_request_x_amzn_tls_version_header_name = (known after apply)
+ routing_http_response_access_control_allow_credentials_header_value = (known after apply)
+ routing_http_response_access_control_allow_headers_header_value = (known after apply)
+ routing_http_response_access_control_allow_methods_header_value = (known after apply)
+ routing_http_response_access_control_allow_origin_header_value = (known after apply)
+ routing_http_response_access_control_expose_headers_header_value = (known after apply)
+ routing_http_response_access_control_max_age_header_value = (known after apply)
+ routing_http_response_content_security_policy_header_value = (known after apply)
+ routing_http_response_server_enabled = (known after apply)
+ routing_http_response_strict_transport_security_header_value = (known after apply)
+ routing_http_response_x_content_type_options_header_value = (known after apply)
+ routing_http_response_x_frame_options_header_value = (known after apply)
+ ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-06"
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Project" = "entity-resolution"
}
+ tcp_idle_timeout_seconds = (known after apply)
+ default_action {
+ order = (known after apply)
+ target_group_arn = (known after apply)
+ type = "forward"
}
+ mutual_authentication (known after apply)
}
# aws_lb_listener_rule.www_to_apex will be created
+ resource "aws_lb_listener_rule" "www_to_apex" {
+ arn = (known after apply)
+ id = (known after apply)
+ listener_arn = (known after apply)
+ priority = 100
+ region = "us-east-2"
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Project" = "entity-resolution"
}
+ action {
+ order = (known after apply)
+ type = "redirect"
+ redirect {
+ host = "dupezero.com"
+ path = "/#{path}"
+ port = "443"
+ protocol = "HTTPS"
+ query = "#{query}"
+ status_code = "HTTP_301"
}
}
+ condition {
+ host_header {
+ regex_values = []
+ values = [
+ "www.dupezero.com",
]
}
}
}
# aws_lb_target_group.web will be created
+ resource "aws_lb_target_group" "web" {
+ arn = (known after apply)
+ arn_suffix = (known after apply)
+ connection_termination = (known after apply)
+ deregistration_delay = "30"
+ id = (known after apply)
+ ip_address_type = (known after apply)
+ lambda_multi_value_headers_enabled = false
+ load_balancer_arns = (known after apply)
+ load_balancing_algorithm_type = (known after apply)
+ load_balancing_anomaly_mitigation = (known after apply)
+ load_balancing_cross_zone_enabled = (known after apply)
+ name = "er-prod-web"
+ name_prefix = (known after apply)
+ port = 3000
+ preserve_client_ip = (known after apply)
+ protocol = "HTTP"
+ protocol_version = (known after apply)
+ proxy_protocol_v2 = false
+ region = "us-east-2"
+ slow_start = 0
+ tags = {
+ "Name" = "er-prod-web"
}
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Name" = "er-prod-web"
+ "Project" = "entity-resolution"
}
+ target_type = "ip"
+ vpc_id = "vpc-06ff8c290ccd6c06f"
+ health_check {
+ enabled = true
+ healthy_threshold = 2
+ interval = 15
+ matcher = "200"
+ path = "/api/healthz"
+ port = "traffic-port"
+ protocol = "HTTP"
+ timeout = 5
+ unhealthy_threshold = 3
}
+ stickiness (known after apply)
+ target_failover (known after apply)
+ target_group_health (known after apply)
+ target_health_state (known after apply)
}
# aws_security_group.alb will be created
+ resource "aws_security_group" "alb" {
+ arn = (known after apply)
+ description = "The internet-facing prod ALB: 80 and 443 from anywhere, egress to pod IPs."
+ egress = (known after apply)
+ id = (known after apply)
+ ingress = (known after apply)
+ name = "er-prod-alb"
+ name_prefix = (known after apply)
+ owner_id = (known after apply)
+ region = "us-east-2"
+ revoke_rules_on_delete = false
+ tags = {
+ "Name" = "er-prod-alb"
}
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Name" = "er-prod-alb"
+ "Project" = "entity-resolution"
}
+ vpc_id = "vpc-06ff8c290ccd6c06f"
}
# aws_vpc_security_group_egress_rule.alb_to_targets will be created
+ resource "aws_vpc_security_group_egress_rule" "alb_to_targets" {
+ arn = (known after apply)
+ cidr_ipv4 = "10.1.0.0/16"
+ description = "To er-web pods in the private subnets"
+ from_port = 3000
+ id = (known after apply)
+ ip_protocol = "tcp"
+ region = "us-east-2"
+ security_group_id = (known after apply)
+ security_group_rule_id = (known after apply)
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Project" = "entity-resolution"
}
+ to_port = 3000
}
# aws_vpc_security_group_ingress_rule.alb_http will be created
+ resource "aws_vpc_security_group_ingress_rule" "alb_http" {
+ arn = (known after apply)
+ cidr_ipv4 = "0.0.0.0/0"
+ description = "HTTP from the internet, redirected to HTTPS by the listener"
+ from_port = 80
+ id = (known after apply)
+ ip_protocol = "tcp"
+ region = "us-east-2"
+ security_group_id = (known after apply)
+ security_group_rule_id = (known after apply)
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Project" = "entity-resolution"
}
+ to_port = 80
}
# aws_vpc_security_group_ingress_rule.alb_https will be created
+ resource "aws_vpc_security_group_ingress_rule" "alb_https" {
+ arn = (known after apply)
+ cidr_ipv4 = "0.0.0.0/0"
+ description = "HTTPS from the internet"
+ from_port = 443
+ id = (known after apply)
+ ip_protocol = "tcp"
+ region = "us-east-2"
+ security_group_id = (known after apply)
+ security_group_rule_id = (known after apply)
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Project" = "entity-resolution"
}
+ to_port = 443
}
# aws_vpc_security_group_ingress_rule.nodes_from_alb will be created
+ resource "aws_vpc_security_group_ingress_rule" "nodes_from_alb" {
+ arn = (known after apply)
+ description = "er-web traffic from the prod ALB"
+ from_port = 3000
+ id = (known after apply)
+ ip_protocol = "tcp"
+ referenced_security_group_id = (known after apply)
+ region = "us-east-2"
+ security_group_id = "sg-020c5aa2c80b3201c"
+ security_group_rule_id = (known after apply)
+ tags_all = {
+ "Environment" = "prod"
+ "ManagedBy" = "terraform"
+ "Project" = "entity-resolution"
}
+ to_port = 3000
}
# 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 (§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 = (known after apply)
+ web_acl_arn = (known after apply)
}
# cloudflare_dns_record.acm_validation["dupezero.com"] will be created
+ resource "cloudflare_dns_record" "acm_validation" {
+ content = (known after apply)
+ created_on = (known after apply)
+ id = (known after apply)
+ include_shadow_metadata = false
+ meta = (known after apply)
+ modified_on = (known after apply)
+ name = (known after apply)
+ proxiable = (known after apply)
+ proxied = false
+ settings = (known after apply)
+ tags = (known after apply)
+ tags_modified_on = (known after apply)
+ ttl = 60
+ type = (known after apply)
+ zone_id = "2f036e2791d0b695a23145e5f4ae1fb7"
}
# cloudflare_dns_record.acm_validation["www.dupezero.com"] will be created
+ resource "cloudflare_dns_record" "acm_validation" {
+ content = (known after apply)
+ created_on = (known after apply)
+ id = (known after apply)
+ include_shadow_metadata = false
+ meta = (known after apply)
+ modified_on = (known after apply)
+ name = (known after apply)
+ proxiable = (known after apply)
+ proxied = false
+ settings = (known after apply)
+ tags = (known after apply)
+ tags_modified_on = (known after apply)
+ ttl = 60
+ type = (known after apply)
+ zone_id = "2f036e2791d0b695a23145e5f4ae1fb7"
}
# cloudflare_dns_record.apex will be created
+ resource "cloudflare_dns_record" "apex" {
+ comment = "Terraform (envs/prod/edge.tf) — the prod ALB. DNS-only: AWS WAF is the edge."
+ comment_modified_on = (known after apply)
+ content = (known after apply)
+ created_on = (known after apply)
+ id = (known after apply)
+ include_shadow_metadata = false
+ meta = (known after apply)
+ modified_on = (known after apply)
+ name = "dupezero.com"
+ proxiable = (known after apply)
+ proxied = false
+ settings = (known after apply)
+ tags = (known after apply)
+ tags_modified_on = (known after apply)
+ ttl = 60
+ type = "CNAME"
+ zone_id = "2f036e2791d0b695a23145e5f4ae1fb7"
}
# cloudflare_dns_record.www will be created
+ resource "cloudflare_dns_record" "www" {
+ comment = "Terraform (envs/prod/edge.tf) — redirected to the apex by the ALB listener rule."
+ comment_modified_on = (known after apply)
+ content = (known after apply)
+ created_on = (known after apply)
+ id = (known after apply)
+ include_shadow_metadata = false
+ meta = (known after apply)
+ modified_on = (known after apply)
+ name = "www.dupezero.com"
+ proxiable = (known after apply)
+ proxied = false
+ settings = (known after apply)
+ tags = (known after apply)
+ tags_modified_on = (known after apply)
+ ttl = 60
+ type = "CNAME"
+ zone_id = "2f036e2791d0b695a23145e5f4ae1fb7"
}
Plan: 18 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ edge_alb_dns_name = (known after apply)
+ edge_certificate_arn = (known after apply)
+ edge_target_group_arn = (known after apply)
+ edge_web_acl_arn = (known after apply)
|
11 tasks done
athvin
added a commit
that referenced
this pull request
Nov 8, 2026
#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: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Merged
11 tasks done
athvin
added a commit
that referenced
this pull request
Nov 8, 2026
… token never applied Two Cloudflare credential mechanisms landed within nine minutes of each other and collided. #912 set `CLOUDFLARE_API_TOKEN` as a job-level `env:` from the `infra-apply-core` Environment secret; #911 added a step exporting it from Secrets Manager for the prod leg. A job-level `env:` takes precedence over `$GITHUB_ENV`, so the value that is empty on the prod leg shadowed the token the step had just written — and `apply (prod)` failed with Cloudflare `9106`, no authorization header at all, on the line after the export step reported success. Precedence was the bug, not the fetch. Verified the fetch itself is sound: the step logged `exported CLOUDFLARE_API_TOKEN ... (53 chars)`, and the same token with an empty `provider "cloudflare" {}` block authenticates locally against provider 5.28.1 — the version CI locks — returning the zone name. #912's reasoning was correct when written. It says the value is "empty on dev and prod, which need no Cloudflare credential", and that stopped being true the moment envs/prod got DNS records. TWO TOKENS, NOT ONE, and this is the part worth keeping. core creates an R2 bucket and needs `Workers R2 Storage: Edit` on the ACCOUNT; prod writes DNS and needs `Zone DNS: Edit` on ONE zone. Measured: the zone-scoped token returns `9109` on `/accounts/<id>` and `10000` on `/accounts/<id>/r2/buckets`, so it cannot do core's work, and a shared token would have to carry both scopes and be strictly broader than either leg needs. So: one variable, one setter, source chosen per leg. The script takes the Environment secret when it is non-empty (core) and falls through to Secrets Manager otherwise (prod), and it is the only thing in the workflow that assigns `CLOUDFLARE_API_TOKEN`. Both branches are self-tested, including that the fall-through FAILS rather than silently exporting nothing, and that a token pasted with a trailing newline is trimmed — untrimmed it would ride into the Authorization header and fail exactly like an absent one. This does not fix `apply (core)`, which fails the same way for its own reason: its Environment secret exists and is populated, but the value does not authenticate. That is #910/#912's to resolve and it was already failing on its own merge, before this. No ticket: this reconciles two merged pull requests rather than adding scope. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This was referenced Nov 8, 2026
Closed
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.
Closes #555
What
The §4.1 prod edge, entirely in Terraform: ACM certificate validated through Cloudflare, an internet-facing ALB with a TLS 1.2 floor and an HTTP→HTTPS redirect, a WAFv2 web ACL with rate rules on the three unauthenticated write paths, and the apex +
wwwDNS records.Why
None of it existed anywhere — not in prod, not in dev. No
aws_acm_certificatein the tree at all, noaws_wafv2_*, no external-dns ever installed, and the chart'singress-web.yamlisenabled: falsewithscheme: internalbecause it was written for dev-over-Tailscale.Proof
bash scripts/ci/tf-validate-all.sh— all five stacksSuccess! The configuration is valid.make skills-check→ok (drift, lint, overrides, generators).scripts-home-check,workflow-shell-checkandtf-static-credentials-checkall clean.terraform fmt -check -recursiveclean.Measured, not assumed: a
-refresh=falseplan of acloudflare_dns_recordwith no credentials in the environment returnsPlan: 1 to add, which is what lets the plan tier stay credential-free.TargetGroupBindingconfirmed present oner-prodaseks.amazonaws.com/v1. The Cloudflare zone was confirmed to bedupezero.comwith 0 existing DNS records, so nothing here overwrites anything.Not applied. The plan tier will show the real count on this PR.
Risk & rollback
Risk: this is the change that makes prod publicly reachable. It is bounded by there being nothing behind the ALB yet — no pods join the target group until #556, so the apex will answer 503 from the ALB rather than serving the app. The ALB carries
enable_deletion_protection = true, so a later destroy or replace fails rather than silently recreating the edge.Rollback:
git revert <merge-sha>then an apply — but note the apply would be a destroy, so the tree-destroy guard will refuse it unless the revert's subject carriesALLOW-DESTROY, and deletion protection must be turned off first. Faster mitigation if the edge misbehaves: delete the two Cloudflare records (the name stops resolving in ~60s at the TTL set here) and leave the AWS side standing.Post-merge ledger
Closed by: agent · session
a7f03c6d-206a-4ae3-a5c3-1c2f74052399onMac· 2026-11-08T21:20:00Zmainis green with this change on it —mainhead is7cfeafc8, which has this commit as an ancestor (git merge-base --is-ancestorconfirmed).rustrun 42523297782 concluded success, 23 jobs, zero failures;infra,frontend,devcontaineranddeployon the same SHA also success.images—n/a — no image inputs changed.Four Terraform files, two module outputs, a CI script and a generated reference; noimagesrun exists for this merge SHA.deploy—n/a — nothing to deploy.No image was built, so nothing rolled. (deployis green onmain's current head independently, after feat(tags): reserved system tags, per-tag permission, tags in export (#805) #875's schema fixup landed.)infrais the relevant one and it is green onmain's head, withapply (core),apply (dev)andapply (prod)all success in run 42523297838. It took three attempts to get there: this merge's ownapply (prod)failed (the WAF description, fix(infra): WAFv2 rejects § in a web ACL description, so prod has no WAF #913) and so did fix(infra): WAFv2 rejects § in a web ACL description, so prod has no WAF #913's (the token shadow, fix(ci): a job-level env: shadows $GITHUB_ENV, so the prod Cloudflare token never applied #919).driftandkindare untouched by this diff.Donethrough the automation — Prod edge #555 readsCLOSED / COMPLETEDand its card readsDone. Not touched by hand.appNodePool, needed before pods can land), ANTHROPIC_API_KEY is empty in er/prod/app/erweb #907 (the emptyANTHROPIC_API_KEY). The second half of the acceptance probe is Prod deploy path #556's, see below.waf-rate-rule-needs-warmup(the first flood never blocks and reads as a broken rule) andworkflow-run-headsha-misattributes-deploy. Theenv:-precedence finding is recorded in fix(ci): a job-level env: shadows $GITHUB_ENV, so the prod Cloudflare token never applied #919's ledger and in the workflow itself.Specific to this change
cloudflare tokenran and exported the token — on the third attempt. It reported success on the first two as well, which was the trap:tf-cloudflare-token: exported CLOUDFLARE_API_TOKEN ... (53 chars)while a job-levelenv:shadowed it. Fixed in fix(ci): a job-level env: shadows $GITHUB_ENV, so the prod Cloudflare token never applied #919; now logs the source it chose.ISSUED—aws acm describe-certificate:Status: ISSUED,dupezero.com: SUCCESS,www.dupezero.com: SUCCESS. Validation took 24 seconds.edge.tf's comment.www301s to the apex —dig +short dupezero.com→18.226.193.19(Cloudflare apex flattening),dig +short www.dupezero.com→ the ALB hostname then the same address.curl -sI https://www.dupezero.com→301 → https://dupezero.com:443/.curl -sI http://dupezero.com→301 → https://dupezero.com:443/./api/auth/login→ 60× 403, while 5 GETs to/from the same address at the same moment → 5× 503 (passed through). That control is the point — it shows the block is path-scoped rather than IP-wide, which the criterion as written would not have established.deferred — #556for the "second IP's legitimate login succeeds" half, which needs pods behind the target group to produce a successful login at all.deferred — #921.deferred — #556. Kept at 60s deliberately while the edge is still being built out, so a mistake is correctable in a minute rather than cached for an hour. Added to Prod deploy path #556's acceptance items, where the condition ("once pods are serving") actually belongs.Context — plan, discoveries, measurements, files
Plan
Plan: 1 to add.wwwredirect rule.wwwrecords.scripts/ci/.Discoveries
frontend/src/lib/site/routes.ts:36hardcodesCANONICAL_ORIGIN = "https://dupezero.com"and argues at length why it is not an environment variable. The marketing pages and the app are the same Next.js app, so prod is one hostname. That settles the hostname question before it is asked.GET /user/tokensreturns9109 Unauthorized, and it cannot read or write zone settings either. It hasZone → DNS Edit+Zone → Zone Read. This removed work rather than adding it: the only thing a second token was for was external-dns, and Terraform owning the records removes external-dns. Zone settings are moot because a DNS-only record means Cloudflare proxies nothing.er-ci-tf-apply-prodalready holdsAdministratorAccess(envs/core/ci-terraform.tf:381), so no IAM grant was needed for the Secrets Manager read — which is what let this be one PR instead of two. The apply-before-merge ordering trap (fix(infra): read bootstrap state in the plan role, and stop running the Rust gate on terraform-only PRs #358, perf(ci): point sccache at S3 — DO NOT MERGE UNTIL THE TERRAFORM IS APPLIED #350) would otherwise have applied.target_type = "ip"the targets are pod addresses, and a pod IP is a secondary address on a node ENI, so the traffic is evaluated against the node security group. The failure mode without it is targets stuck unhealthy with nothing naming the cause./api/healthzis in the proxy's PUBLIC_PATHS (frontend/src/proxy.ts:25). That is load-bearing for the health check: any path not in that list answers a session-less request with a 307 to/login, which fails the check — so a health check on/would mark every healthy pod unhealthy.Measurements
Files
infra/terraform/envs/prod/edge.tf(new) — the whole edgeinfra/terraform/envs/prod/versions.tf— the cloudflare providerinfra/terraform/modules/eks/main.tf—cluster_security_group_idoutputinfra/terraform/modules/network/main.tf—vpc_cidroutputscripts/ci/tf-cloudflare-token.sh(new) — the apply-tier fetch.github/workflows/infra.yml— the prod-only step calling it