Deprovision Stripe test hubs on production platform
Use this when production Cloudflare customer hubs (*.lovely-hub.com) were created with Stripe Test billing on the live platform admin — not platform-sandbox stack sites. Teardown uses the same v5 deprovision pipeline as any Terraform-managed customer hub.
Example (2025 cleanup): cornwalls, cornwalls-2, cornwalls-3 on platform.lovely-home.co.uk with test-mode Checkout. Replace site ids and hostnames below with your case.
Authoritative detail: platform-provision.md, platform-admin.md, platform-billing.md, support-model.md.
Registry pattern (example)
site_id | Hostname | Terraform stack | State key (R2) |
|---|---|---|---|
cornwalls | cornwalls.lovely-hub.com | customers | home-dashboard/customers/cornwalls.tfstate |
cornwalls-2 | cornwalls-2.lovely-hub.com | customers | home-dashboard/customers/cornwalls-2.tfstate |
Sites are in platform/sites.yaml with terraform: true. They are not protected (unlike demo / production household slugs).
Choose one path (do not mix for the same site)
| Path | When to use | Entry point |
|---|---|---|
| A — Platform admin Delete (recommended) | Standard “remove from git registry → CI tears down infra”; subscriptions are test-only and cleaned up separately | Wizard Delete → merge PR |
| B — Billing deprovision | Same pipeline as Stripe cancel (archive-first, registry drop snapshot, inline destroy) | Cancel sub in Stripe Test or workflow Platform site billing deprovision |
Path A is documented in platform-provision.md. Path B uses .github/workflows/platform-site-billing-deprovision.yml and scripts/billing-deprovision-hub-site.mjs (local emergency only).
Do not run Path A (Delete PR) and Path B on the same site_id.
Before you start (all paths)
- Confirm Stripe mode on platform admin — banner / settings should show test. Cancel subscriptions only in Stripe Dashboard Test mode, never Live.
- Platform admin → Sites — note
registry_last_error,provision_last_error, or billing errors. - Do not manually delete Workers, D1, R2, Pages, DNS, or Terraform state. Do not hand-edit
platform/sites.yamlwithout the wizard or billing scripts.
Path A — Wizard Delete (preferred)
Repeat once per site (one delete → one PR → one deprovision run). CI deprovisions removed sites with max-parallel: 4 on the customers stack.
Per site
- Production platform admin → Sites → card for the test hub.
- Click Delete, confirm hostname (dispatches
platform-site-manage.ymlviaplatform-site-manage.mjs). - Merge the
platform/site-*delete PR tomain. - Wait for Platform site deprovision green for that
site_id. - Merge follow-up PR
platform: drop {site_id} contract from platform manifestif opened. - Verify hostname no longer serves the hub; site card gone from platform admin.
- (Optional) Stripe Test mode — cancel remaining subscription/customer for that slug.
What CI runs
scripts/deprovision-hub-site.mjs: archive to platform R2 → empty hub R2 → Pages prune → terraform destroy (customers stack) → delete Worker → manifest + platform admin redeploy → prune HUB_PROXY_SECRETS_JSON when token allows.
Manual retry (Path A — site already off sites.yaml)
- Actions → Platform site deprovision →
site_id,terraform_stack:customers,use_github_hosted: true if self-hosted runner unavailable (ci-runner-strategy.md). - Local (site must not be in
sites.yaml):
node scripts/deprovision-hub-site.mjs <site_id>
# optional: --skip-platform-adminPath B — Billing deprovision
Option B1 — Cancel in Stripe (Test mode)
- Confirm platform admin /
STRIPE_MODEis test. - Stripe Test mode → cancel subscription (immediate cancel tears down).
- Webhook dispatches Platform site billing deprovision when hub was live with
trialing/active/past_due. - Verify same as Path A step 6.
Option B2 — Manual billing deprovision workflow
Site must still be listed in platform/sites.yaml.
- Actions → Platform site billing deprovision →
site_id,use_github_hostedif needed. - Do not also open a wizard Delete PR for that id.
Local emergency (Path B only)
node scripts/billing-deprovision-hub-site.mjs <site_id> --confirm-hostname <hostname>After deprovision — reuse slugs
After deprovision is green and manifest follow-ups are merged, purge platform billing D1 rows (does not destroy Cloudflare):
node scripts/purge-platform-site-for-reuse.mjs <site_id>Refuses to run if the site is still in sites.yaml or manifest still shows a Terraform contract.
Archives in platform R2 may remain for ~12 months (reinstate window) — expected.
Batch vs one-at-a-time
| Approach | Notes |
|---|---|
| Sequential (safest) | Finish Path A or B for one site before the next. |
| Parallel delete PRs | Multiple wizard deletes → CI queues up to four customer deprovisions; retry any red job individually. |
| Single PR removing many sites | Not exposed in wizard (one site per delete). Prefer wizard per site. |
Risks and common mistakes
| Risk | Mitigation |
|---|---|
| Cancel in Stripe Live while platform is in test mode (or vice versa) | Match platform admin mode to Stripe Dashboard mode. |
| Removing yaml without deprovision | Leaves Workers, D1, R2, Pages, tfstate — run manual Platform site deprovision. |
| Wrong Terraform stack | Use terraform_stack=customers and per-site init (platform-terraform.md). |
| Purging D1 before deprovision completes | purge-platform-site-for-reuse.mjs blocks if registry/manifest still shows the site. |
| Recreating same id while deprovision runs | Wait until deprovision is green (platform-provision.md). |
Workflow quick reference
Script index: ops-sandbox-scripts.md.