Designing Ephemeral Zero Trust Demo Environments with Cloudflare Tunnel, UpCloud, Drizzle, and GraphPG
Interactive product demos sit in an awkward spot between marketing sites and production infrastructure: visitors want real database state and query inspection, yet leaving an internet-facing database server running permanently invites credential scanning and unnecessary cloud bills. Most teams respond either by mocking everything in client JavaScript or by maintaining long-lived staging servers with SSH keys, bastion rules, and manual cleanup jobs. In this blueprint I show how we connect Nuxt sites on Cloudflare Workers (RetroAgile and Innovi Care) to a shared, disposable PostgreSQL 18 and graphpg backend on UpCloud that closes every public inbound port and survives VM destruction cleanly.
We built this architecture on top of the n8n reference stack on UpCloud and packaged it in both Pulumi (TypeScript) and OpenTofu (HCL) inside RetroAgile's infra-demo package. Because both demo schemas and seed procedures live in source control, tearing the server down costs zero between sales calls, and bringing it back reproduces the same databases automatically.

Locking the origin VPS to zero inbound ports
An ephemeral demo box should not trust perimeter rules you configured manually over SSH. In both the Pulumi and OpenTofu templates, an upcloud_server_firewall_rules resource sets default_action = "drop" for inbound IPv4 and IPv6 traffic, so port 5432, port 22, and both API ports stay unreachable from the public internet.
Connectivity runs strictly inside-out through cloudflared. The container authenticates outbound to Cloudflare Edge with a tunnel token provisioned in the same stack and routes hostnames demo-api.retroagile.com to http://127.0.0.1:8081 and demo-api.innovi.care to http://127.0.0.1:8082. Even inside the server, both GraphPG listeners bind only to loopback, rather than 0.0.0.0.
Before traffic leaves Cloudflare Access toward that tunnel, an Access Application enforces a nonIdentity service-token policy. Only server routes inside our Cloudflare Workers hold CF_ACCESS_CLIENT_ID and CF_ACCESS_CLIENT_SECRET as encrypted runtime secrets, so visitors inspect live telemetry and clinical cohorts in the UI without ever receiving direct origin credentials. You can apply the same Zero Trust pattern in other clouds too, for example AWS SSM Session Manager with PrivateLink or Tailscale ACLs, whenever you want private origin access without inbound security groups.
Separating two demos on one Postgres 18 cluster
For a proof of concept, two managed Postgres clusters add operational noise without helping the visitor. Our Docker Compose stack runs one postgres:18-alpine engine capped at 320 MB and initializes two isolated databases in 00-init-multi-db.sql:
retroagile: Stores OTLP spans, repository metadata, Spec-Readiness audits, and pull-request lifecycle ranges described in the RetroAgile architecture write-up.innovi_care: Stores FHIR R4patient,encounter,observation, andmedication_requesttables with PostgreSQL 18 generated columns projected fromjsonbpayloads alongside foreign-key constraints and GIN indexes (FHIR agentic factory article).
Rather than keeping separate hand-written REST and GraphQL backends running for each product, we mount two graphpg 1.3.0 configurations pointing at ports 8081 and 8082. How the dual containers fit inside a 1 GB host is detailed in the engineering breakdown on running two GraphPG APIs on a €3 UpCloud VPS.

Drizzle migrations and volatile reset RPCs replace backups
Production databases need point-in-time recovery, automated snapshots, and migration gates. Demo environments work better when you skip backup storage altogether and make clean state cheap to recreate on demand.
Both repositories manage their schema in Drizzle ORM (drizzle-kit generate), producing standard SQL files plus one custom volatile PostgreSQL function per database: reset_retroagile_demo() and reset_innovi_care_demo(). On boot, an idempotent db-migrate-seed init container applies unrecorded .sql files and runs the reset function. A cron entry on the host triggers the same script every 30 minutes, and GraphPG exposes each VOLATILE function directly as a GraphQL mutation so the Reset Demo DB button on either website restores the seeded dataset in one call:
CREATE OR REPLACE FUNCTION reset_innovi_care_demo()
RETURNS jsonb
LANGUAGE plpgsql
VOLATILE
AS $$
DECLARE
v_now timestamptz := clock_timestamp();
BEGIN
TRUNCATE TABLE medication_request, observation, encounter, patient
RESTART IDENTITY CASCADE;
-- deterministic seed rows inserted with relative clock_timestamp() intervals
RETURN jsonb_build_object(
'status', 'reset',
'database', 'innovi_care',
'patients_seeded', 4,
'reset_at', v_now
);
END;
$$;
PRO Tip #1: Wrapping the TRUNCATE ... RESTART IDENTITY CASCADE and seed INSERT statements inside a single VOLATILE PL/pgSQL function keeps one authoritative reset path across Docker entrypoint initialization, 30-minute cron sweeps, local CLI seeding, and live UI resets, rather than duplicating seed logic in shell and JavaScript.
Graceful edge fallback when the server is destroyed
An ephemeral environment has to handle its own absence cleanly. When pulumi destroy or tofu destroy deletes the UpCloud VM and tunnel, any visitor clicking Inspect Compiled SQL or Reset Demo DB in Innovi Care or RetroAgile should still see a responsive workspace rather than a 502 error.
In both Nuxt Nitro server routes (/api/demo/graphpg and /api/demo/reset), the Worker sends an HTTPS request to the tunneled GraphPG endpoint with a short timeout whenever GRAPHPG_URL exists in runtime config. When that variable is empty or the server is unreachable, the Worker returns mode: "deterministic-fallback" with the same seeded dataset, JSONB reset receipt, and compiled SQL query structure, tagging whether each response came from live-vps or deterministic-fallback.
Notice what we verified locally versus what stays off by design. Both IaC stacks, Compose validation, TypeScript builds for both Cloudflare Worker applications, and Drizzle SQL generation passed locally, while live UpCloud provisioning stays unexecuted so no paid infrastructure runs until a workshop requires it.
Work with Innovi Pro
Zero Trust demo automation removes the ongoing security and billing tax from technical pre-sales and regulated SaaS evaluation sandboxes, especially when clinical schemas or multi-repo telemetry require strict boundary isolation. You can also adapt this disposable Terraform or Pulumi pattern for short-lived PR preview databases using Managed PostgreSQL, Fly.io machines, or Neon branches when managed scaling matters more than low cost.
If your team wants an architectural review of your preview environments, PostgreSQL security model, or API layer, explore our software architecture audit or book a discovery call.
