Skip to content
Operate

Uninstall and inventory

See every Google Cloud resource MedHook created in your project, and remove exactly those, with your data kept unless you ask.

On this page

Two scripts in the release bundle answer "what did MedHook create here?" and "remove it, and nothing else". Both identify MedHook's resources the same way, and neither touches anything without MedHook's markers.

How MedHook's resources are marked

  • Created by Terraform: labels app=medhook, managed_by=terraform and environment wherever Google Cloud supports labels. Networks, routers, addresses, VPN gateways, service accounts and custom roles cannot be labelled, so they carry the install's name prefix (<project_name>-<environment>, Terraform output name_prefix).
  • Created by the engine at runtime: the VPN tunnels, routes, peer gateways and BGP sessions you add in Settings · VPN Tunnels. Each is named with the install's name prefix and carries the engine's description (on newer engines followed by the tunnel id) or its label managed-by=medhook. One counts as MedHook's only when it has both the prefix and one of those markers. A resource of yours that shares the prefix, or copies the description under another name, is never listed or removed.

Inventory

deploy/inventory.sh prints one table of every resource MedHook created in the project: kind, name, location, the marker that proves it, and whether Terraform or the engine created it. It only reads.

bash
PROJECT_ID="$PROJECT_ID" REGION="$REGION" NAME_PREFIX=medhook-production deploy/inventory.sh

Add FORMAT=tsv for a spreadsheet. Labelled resources come from Cloud Asset Inventory when you can read it; otherwise the script asks each service in turn.

In the engine

Settings › Resources shows the same list inside the engine, for an engine admin: each resource's type, name, region, whether the engine or Terraform created it, the marker that shows it, and a link to it in the Google Cloud console. It reads with the engine's own service account and changes nothing.

The engine's runtime role lists its VPN tunnels and routes. A list the engine's account can't read shows a "Needs" row with the permission and a read-only role that grants it, such as roles/compute.networkViewer for gateways, routers and firewall rules (engine_vpn_external_visibility = true in Terraform grants it), roles/storage.bucketViewer for buckets or roles/pubsub.viewer for Pub/Sub. Grant them if you want the page complete, or run deploy/inventory.sh as yourself, which lists everything. The same list is GET /api/settings/resources.

Uninstall

deploy/uninstall.sh is a dry run unless you add --confirm. The dry run prints every resource it would remove and the Terraform plan of the destroy, and changes nothing.

bash
PROJECT_ID="$PROJECT_ID" REGION="$REGION" NAME_PREFIX=medhook-production \
  CLUSTER=medhook-production-gke CLUSTER_LOCATION="$ZONE" TF_DIR=terraform/gke \
  deploy/uninstall.sh

It works in this order:

  1. The engine's VPN tunnels, routes, peer gateways and BGP sessions. They go first: Terraform does not know them, and the gateways and router it owns cannot be deleted while they exist.
  2. The Helm release, if it is the MedHook chart. Google Cloud then removes the load balancers it made.
  3. Terraform: a destroy of the MedHook module's resources only, never anything else in your Terraform state.

Your data stays unless you ask

Without --include-data, the database, the secrets (including the master key), the buckets, the encryption keys, the FHIR store and in-cluster database volumes are kept, and the script lists them. With --include-data they go too. Back up first: export the database and the audit archive, and keep the master key in escrow. Terraform still refuses to delete the master key, the generated secrets and the FHIR store on purpose; the script prints them for you to delete by hand. The audit archive keeps its objects until its retention period ends.

Deletion protection

Production clusters and databases are protected from deletion. The script checks before it removes anything and stops if the cluster is protected. Add --disable-deletion-protection to lift the cluster's protection (and the database's, with --include-data) with one targeted Terraform apply first.

Reference