Skip to content

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_idHostnameTerraform stackState key (R2)
cornwallscornwalls.lovely-hub.comcustomershome-dashboard/customers/cornwalls.tfstate
cornwalls-2cornwalls-2.lovely-hub.comcustomershome-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) ​

PathWhen to useEntry point
A — Platform admin Delete (recommended)Standard “remove from git registry → CI tears down infra”; subscriptions are test-only and cleaned up separatelyWizard Delete → merge PR
B — Billing deprovisionSame 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) ​

  1. Confirm Stripe mode on platform admin — banner / settings should show test. Cancel subscriptions only in Stripe Dashboard Test mode, never Live.
  2. Platform admin → Sites — note registry_last_error, provision_last_error, or billing errors.
  3. Do not manually delete Workers, D1, R2, Pages, DNS, or Terraform state. Do not hand-edit platform/sites.yaml without 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 ​

  1. Production platform admin → Sites → card for the test hub.
  2. Click Delete, confirm hostname (dispatches platform-site-manage.yml via platform-site-manage.mjs).
  3. Merge the platform/site-* delete PR to main.
  4. Wait for Platform site deprovision green for that site_id.
  5. Merge follow-up PR platform: drop {site_id} contract from platform manifest if opened.
  6. Verify hostname no longer serves the hub; site card gone from platform admin.
  7. (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):
bash
node scripts/deprovision-hub-site.mjs <site_id>
# optional: --skip-platform-admin

Path B — Billing deprovision ​

Option B1 — Cancel in Stripe (Test mode) ​

  1. Confirm platform admin / STRIPE_MODE is test.
  2. Stripe Test mode → cancel subscription (immediate cancel tears down).
  3. Webhook dispatches Platform site billing deprovision when hub was live with trialing / active / past_due.
  4. Verify same as Path A step 6.

Option B2 — Manual billing deprovision workflow ​

Site must still be listed in platform/sites.yaml.

  1. Actions → Platform site billing deprovision → site_id, use_github_hosted if needed.
  2. Do not also open a wizard Delete PR for that id.

Local emergency (Path B only) ​

bash
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):

bash
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 ​

ApproachNotes
Sequential (safest)Finish Path A or B for one site before the next.
Parallel delete PRsMultiple wizard deletes → CI queues up to four customer deprovisions; retry any red job individually.
Single PR removing many sitesNot exposed in wizard (one site per delete). Prefer wizard per site.

Risks and common mistakes ​

RiskMitigation
Cancel in Stripe Live while platform is in test mode (or vice versa)Match platform admin mode to Stripe Dashboard mode.
Removing yaml without deprovisionLeaves Workers, D1, R2, Pages, tfstate — run manual Platform site deprovision.
Wrong Terraform stackUse terraform_stack=customers and per-site init (platform-terraform.md).
Purging D1 before deprovision completespurge-platform-site-for-reuse.mjs blocks if registry/manifest still shows the site.
Recreating same id while deprovision runsWait until deprovision is green (platform-provision.md).

Workflow quick reference ​

Script index: ops-sandbox-scripts.md.