From d4b30f2574ab33d4db69601d2785a5b1cb306f3d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 29 Sep 2026 23:19:37 +0000 Subject: [PATCH 1/3] feat(infra): demo.pywire.dev DNS record for the example Workers Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NUEPGc2SgMUHxx4Z28HS8v --- infra/main.tf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/infra/main.tf b/infra/main.tf index adaa34d..d11b71e 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -119,6 +119,20 @@ resource "cloudflare_dns_record" "nightly" { ttl = 1 } +# --- Demos (demo.pywire.dev) --- +# Workers only: the landing page and each example are Workers deployed from +# pywire/pywire (Deploy Examples workflow) with their own routes. A proxied +# record is all the hostname needs; 100:: is the placeholder Cloudflare +# documents for a Worker-only hostname. +resource "cloudflare_dns_record" "demo" { + zone_id = var.zone_id + name = "demo" + content = "100::" + type = "AAAA" + proxied = true + ttl = 1 +} + # --- VS Code Marketplace Domain Verification --- resource "cloudflare_dns_record" "vscode_verification" { zone_id = var.zone_id From 4baa3165a522c7f244c02b971c086195a4512199 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 30 Sep 2026 00:42:21 +0000 Subject: [PATCH 2/3] feat(infra): demo.pywire.dev routes for the example Workers Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NUEPGc2SgMUHxx4Z28HS8v --- infra/main.tf | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/infra/main.tf b/infra/main.tf index d11b71e..fecded9 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -120,19 +120,42 @@ resource "cloudflare_dns_record" "nightly" { } # --- Demos (demo.pywire.dev) --- -# Workers only: the landing page and each example are Workers deployed from -# pywire/pywire (Deploy Examples workflow) with their own routes. A proxied -# record is all the hostname needs; 100:: is the placeholder Cloudflare -# documents for a Worker-only hostname. +# The landing page and each example are Workers whose code pywire/pywire's +# Deploy Examples workflow uploads. Their DNS and routes live here. The Workers +# must exist before these routes apply, so the first apply follows that +# workflow's first run. resource "cloudflare_dns_record" "demo" { zone_id = var.zone_id name = "demo" - content = "100::" + content = "100::" # Cloudflare's placeholder for a Worker-only hostname type = "AAAA" proxied = true ttl = 1 } +locals { + # Each example is served under / by the Worker pywire-demo-. + demo_examples = ["edge-stateless", "form-builder"] + demo_routes = merge( + { "site" = { pattern = "demo.pywire.dev/*", script = "pywire-demo" } }, + { for name in local.demo_examples : name => { + pattern = "demo.pywire.dev/${name}", script = "pywire-demo-${name}" + } }, + { for name in local.demo_examples : "${name}/*" => { + pattern = "demo.pywire.dev/${name}/*", script = "pywire-demo-${name}" + } }, + ) +} + +# Cloudflare sends a request to the most specific matching route, so the +# example routes win over the landing page's catch-all. +resource "cloudflare_workers_route" "demo" { + for_each = local.demo_routes + zone_id = var.zone_id + pattern = each.value.pattern + script = each.value.script +} + # --- VS Code Marketplace Domain Verification --- resource "cloudflare_dns_record" "vscode_verification" { zone_id = var.zone_id From 96e7904862b3b717633d895cfdaedac0f399645f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 30 Sep 2026 00:56:20 +0000 Subject: [PATCH 3/3] feat(infra): create the demo Workers in Terraform Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NUEPGc2SgMUHxx4Z28HS8v --- infra/main.tf | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/infra/main.tf b/infra/main.tf index fecded9..7fd80c4 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -120,10 +120,11 @@ resource "cloudflare_dns_record" "nightly" { } # --- Demos (demo.pywire.dev) --- -# The landing page and each example are Workers whose code pywire/pywire's -# Deploy Examples workflow uploads. Their DNS and routes live here. The Workers -# must exist before these routes apply, so the first apply follows that -# workflow's first run. +# The landing page and each example are Workers. Terraform creates them and +# owns their DNS and routes; pywire/pywire's Deploy Examples workflow only +# uploads their code and vars, the way Pages deployments go to the Pages +# projects above. Secrets are set with `wrangler secret put` so they stay out +# of state. resource "cloudflare_dns_record" "demo" { zone_id = var.zone_id name = "demo" @@ -136,24 +137,41 @@ resource "cloudflare_dns_record" "demo" { locals { # Each example is served under / by the Worker pywire-demo-. demo_examples = ["edge-stateless", "form-builder"] + demo_workers = merge( + { "site" = "pywire-demo" }, + { for name in local.demo_examples : name => "pywire-demo-${name}" }, + ) demo_routes = merge( - { "site" = { pattern = "demo.pywire.dev/*", script = "pywire-demo" } }, + { "site" = { pattern = "demo.pywire.dev/*", worker = "site" } }, { for name in local.demo_examples : name => { - pattern = "demo.pywire.dev/${name}", script = "pywire-demo-${name}" + pattern = "demo.pywire.dev/${name}", worker = name } }, { for name in local.demo_examples : "${name}/*" => { - pattern = "demo.pywire.dev/${name}/*", script = "pywire-demo-${name}" + pattern = "demo.pywire.dev/${name}/*", worker = name } }, ) } +resource "cloudflare_worker" "demo" { + for_each = local.demo_workers + account_id = var.account_id + name = each.value + + # Only reachable through the routes below, like workers_dev = false and + # preview_urls = false in each wrangler.toml. + subdomain = { + enabled = false + previews_enabled = false + } +} + # Cloudflare sends a request to the most specific matching route, so the # example routes win over the landing page's catch-all. resource "cloudflare_workers_route" "demo" { for_each = local.demo_routes zone_id = var.zone_id pattern = each.value.pattern - script = each.value.script + script = cloudflare_worker.demo[each.value.worker].name } # --- VS Code Marketplace Domain Verification ---