From 6916eb95f61a47bdf9e1063acb6f6bcfef46367e Mon Sep 17 00:00:00 2001 From: pat-s Date: Fri, 7 Aug 2026 14:01:11 +0000 Subject: [PATCH] feat(cdn): manage the edge middleware script from this repo - add bunnynet_compute_script.rpkgs_router, sourced from edge/rpkgs-router.ts, so the middleware is reviewed and deployed like the rest of the config - add the UNION_SLOTS script variable, empty until a slot carries a union index - point the pull zone's middleware_script at the resource instead of the hard-coded id 29277, which the script is adopted from via tofu import --- cdn.tf | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cdn.tf b/cdn.tf index 8a950f5..fe1b25f 100644 --- a/cdn.tf +++ b/cdn.tf @@ -52,6 +52,29 @@ ### cran.rpkgs.com +# The edge middleware that resolves the bare cran.rpkgs.com form to an +# / slot and routes PACKAGES* to the per-R-minor slot. The source of +# truth is edge/rpkgs-router.ts; `tofu apply` publishes a new release. +# +# The script pre-dates this configuration, so it is adopted rather than created: +# tofu import bunnynet_compute_script.rpkgs_router 29277 +resource "bunnynet_compute_script" "rpkgs_router" { + type = "middleware" + name = "rpkgs-router" + content = file("${path.module}/edge/rpkgs-router.ts") +} + +# Slots ("/", comma separated) whose per-minor index bincraft has +# already republished as a union of the per-minor and flat slots. Routing to a +# slot that is not listed here would hide every package the per-minor index does +# not carry, so this stays empty until a slot has been backfilled. +resource "bunnynet_compute_script_variable" "rpkgs_router_union_slots" { + script = bunnynet_compute_script.rpkgs_router.id + name = "UNION_SLOTS" + default_value = "" + required = false +} + resource "bunnynet_pullzone" "cran_rpkgs_com" { name = "cran-rpkgs" @@ -64,7 +87,7 @@ resource "bunnynet_pullzone" "cran_rpkgs_com" { origin { type = "OriginUrl" url = "https://devxy-rpkgs-binaries.s3.eu-central-003.backblazeb2.com" - middleware_script = 29277 + middleware_script = bunnynet_compute_script.rpkgs_router.id } routing {