Skip to content

Deployment runbook

The primary phone demo is the Vue static snapshot on Cloudflare Pages. It has no API/database/cold-start dependency. The Cloud Run API is optional, private (Cloud Run IAM), synthetic-only, and read-only. Forge Studio is a separate static Pages project; its built site must be supplied from its own repository.

No infrastructure has been applied or sites uploaded by this task. Commands below that create resources, upload artifacts, or change services require Andrew's explicit deployment approval. A budget sends alerts; it does not cap spending.

Toolchain and configuration

  • .NET SDK 10.0.301, cdktn CLI 0.25.0, Terraform 1.17.1.
  • Providers pinned: Google/google-beta 7.25.0, Cloudflare 5.17.0. The referenced fleet-infra/policy/providers.json was unavailable locally and at the attempted GitHub locations. Reconcile these pins with that policy before approval; this is not claimed as verified policy parity.
  • Supply billing_account without a default via TF_VAR_billing_account or an ignored *.auto.tfvars file; region us-central1.
  • Supply cloudflare_account_id without a default via TF_VAR_cloudflare_account_id or an ignored *.auto.tfvars file.
  • Backend bucket is passed at init, never embedded in generated configuration. The synthesized prefixes are fhir-demo/gcp and fhir-demo/cf. A constructor placeholder bucket is removed by an override before synthesis, matching the fleet-infra partial-backend pattern.
  • Google Application Default Credentials must already be available for planning. Cloudflare uses CLOUDFLARE_API_TOKEN from the environment. Never put credentials in source, tfvars, or logs.
  • GCP project creation/billing linkage, API enablement, service-account creation, Cloud Run/Artifact Registry administration, and billing-budget permissions are prerequisites. Cloud Run has no allUsers invoker grant; use an authorized IAM identity for API access. The public demo is the static Pages site.

Provider schemas: Cloud Run, Artifact Registry, Pages.

1. Synth and validate (local; no credentials)

From the repository root, PowerShell:

Set-Location infra/FhirDemo.Deploy
cdktn synth --output cdktn.out
Copy-Item locks/fhir-demo-gcp.lock.hcl cdktn.out/stacks/fhir-demo-gcp/.terraform.lock.hcl
Copy-Item locks/fhir-demo-cf.lock.hcl cdktn.out/stacks/fhir-demo-cf/.terraform.lock.hcl
terraform '-chdir=cdktn.out/stacks/fhir-demo-gcp' init -backend=false -input=false -lockfile=readonly
terraform '-chdir=cdktn.out/stacks/fhir-demo-gcp' validate
terraform '-chdir=cdktn.out/stacks/fhir-demo-cf' init -backend=false -input=false -lockfile=readonly
terraform '-chdir=cdktn.out/stacks/fhir-demo-cf' validate

Both cdktf.json and cdktn.json are intentional: CLI 0.25.0 still reads the former filename. The stack project is separate from the existing Azure architecture sample.

2. Plan against the existing remote backend

Select a stable, globally unique suffix (1–11 lowercase letters/digits). Do not change it between plans. Set credentials through the normal approved login/secret process if they are not already available; the worker does not log in or provision credentials.

$env:TF_VAR_project_suffix = 'YOURSUFFIX'
$env:TF_VAR_billing_account = 'YOUR-BILLING-ACCOUNT'
$env:TF_VAR_cloudflare_account_id = 'YOUR-CLOUDFLARE-ACCOUNT'
terraform '-chdir=cdktn.out/stacks/fhir-demo-gcp' init -reconfigure -input=false '-backend-config=bucket=jones-gaffney-fleet-admin-tfstate'
terraform '-chdir=cdktn.out/stacks/fhir-demo-gcp' plan -input=false -out=tfplan
terraform '-chdir=cdktn.out/stacks/fhir-demo-cf' init -reconfigure -input=false '-backend-config=bucket=jones-gaffney-fleet-admin-tfstate'
terraform '-chdir=cdktn.out/stacks/fhir-demo-cf' plan -input=false -out=tfplan

Review both plans, costs, private API access, billing permissions, and the provider-policy reconciliation with Andrew. Keep state and saved plans out of Git. If credentials are unavailable, stop here and record the blocker; synth/validate do not prove account authorization.

3. Apply only after Andrew approves the saved plans

# [Andrew approves these exact plans]
terraform '-chdir=cdktn.out/stacks/fhir-demo-gcp' apply tfplan
terraform '-chdir=cdktn.out/stacks/fhir-demo-cf' apply tfplan
$project = terraform '-chdir=cdktn.out/stacks/fhir-demo-gcp' output -raw project_id

Cloud Run initially runs Google's bootstrap hello image. Terraform deliberately ignores subsequent image changes; the following release step replaces that bootstrap. Runtime service account has no project roles. Artifact Registry retains at least the ten most recent images, deleting other images older than one day. Services and project are protected from accidental teardown.

4. Build and release the optional API (after approval)

From the repository root, with $project from step 3:

Set-Location ../..
$tag = git rev-parse --short HEAD
$image = "us-central1-docker.pkg.dev/$project/app/fhir-demo-api:$tag"
gcloud builds submit --project=$project --region=us-central1 --tag=$image .
gcloud run services update fhir-demo-api --project=$project --region=us-central1 --image=$image

The Cloud Build execution account needs Artifact Registry write, build-source read, and logging permissions. New projects may lack these grants; resolve the exact build-account permissions before submitting, under Andrew's approval. Do not grant these roles to the API runtime account.

The Dockerfile publishes only the API and a small C# build-time fixture seeder. It seeds SQLite twice from committed synthetic fixtures and never copies a host database. No sibling EFCore.DuckDB checkout is required. The API runs as non-root, binds $PORT (default 8080), and sets Demo__ReadOnly=true. The stack explicitly sets Demo__PublicSynthetic=true to permit the container bind; Cloud Run IAM still requires authenticated invocation. SQLite is ephemeral per instance; this is suitable for the read-only fixture demo, not durable writes. Reports use the existing operational/SVG fallback because the image has no lakehouse database. Check /api/patients, /api/dashboard, /api/reports/population, and verify POST /api/sync returns 403. POST /cds-services/patient-risk remains read-only compute.

5. Upload the static sites (after approval)

From the repository root:

dotnet run --project src/FhirDemo.Cli -- snapshot --out web/public/snapshot
Set-Location web
npm ci
npm run build:snapshot
npx wrangler pages deploy dist --project-name=fhir-pipeline-demo --branch=main
Set-Location ..
# Supply the reviewed, already-built Forge Studio directory; it is outside this repo.
$forgeDist = 'C:/path/to/forge-studio/dist'
npx wrangler pages deploy $forgeDist --project-name=forge-studio --branch=main

Use only default *.pages.dev/*.run.app hostnames. No DNS or domain purchases. Pages projects have no Git integration; uploads are explicit. Test the deployed phone flow: Overview → patient chart/CDS → Add allergy (local JSON preview) → Compare. Snapshot allergy JSON is an in-browser demonstration; it is not submitted or persisted to a backend.

NOT DONE

  • Terraform plan: skipped because this PC has no Google ADC/env credentials or Cloudflare token. No infrastructure apply, Cloud Build submission, Cloud Run update, or Pages upload was executed.
  • Fleet provider-policy reconciliation: referenced fleet-infra policy unavailable in this checkout; required before approval.
  • Forge Studio artifact is outside this repo and must be supplied for upload.
  • Static Pages and authenticated private API verification await an approved deployment.