Skip to content
Operate

Least privilege

The exact permissions the person or CI that runs the install needs, and the ones the engine holds at runtime, with no roles/owner.

On this page

The install never needs roles/owner. Two identities need permissions, and each gets exactly the set for what it does:

  • The installer: whoever runs terraform apply, a person or your CI's service account.
  • The engine at runtime: its Workload Identity service account, which manages VPN tunnels.

The lists ship in the release bundle, one file per part of the install, under terraform/gke/modules/medhook/iam/. Terraform, the preflight check and these docs all read the same files. Each file also names the predefined roles that cover it and the Google APIs it uses.

The installer

What the installer needs follows your Terraform settings. terraform output install_features lists the parts your configuration installs.

PartNeeded whenPredefined roles that cover it
corealways: service accounts, custom roles, secrets, registry, buckets, VPN gatewayproject IAM admin, service account admin, role admin, Secret Manager admin, Artifact Registry admin, Storage admin, network admin
apisTerraform enables the Google APIs (the default)Service Usage admin
networkTerraform creates the VPCnetwork admin
cloud-natTerraform creates Cloud NAT (the default)network admin
clusterTerraform creates the GKE clustercluster admin, service account user, Cloud KMS admin, container developer
cloudsqlTerraform creates Cloud SQL (the default)Cloud SQL admin, Service Networking admin
alertsTerraform creates Cloud Monitoring alerts (the default)alert policy, uptime check and notification channel editors, logging config writer
ha-vpn, memorystore, cloud-armor, fhir-store, bigquery, cmek, github, sql-verifyyou turn those features onnamed in each file

Bring your own VPC, cluster, database or monitoring and the matching parts drop out. See Bring your own infrastructure.

Grant it

Use the installer module from your own IAM Terraform, run by your IAM admin before the first apply:

hcl
module "medhook_installer" {
  source            = "./terraform/gke/modules/medhook-iam"
  project_id        = "demohealth-medhook"
  installer_members = ["serviceAccount:tf-ci@demohealth-platform.iam.gserviceaccount.com"]
  features          = ["core", "network", "cloud-nat", "cluster", "cloudsql", "alerts"]
  role_suffix       = "dh01"                  # the same iam_role_suffix as the MedHook module
  expires           = "2027-01-31T00:00:00Z" # optional: every grant ends then
}

It creates one custom role with exactly those permissions, except the right to change project IAM. That one can grant anything, so it comes from a separate project IAM admin grant whose IAM condition lets the installer grant only the roles MedHook grants. For organizations that do not allow custom roles, grant_mode = "predefined_roles" grants the predefined roles instead.

Without Terraform, print the role as a file for gcloud:

bash
deploy/iam.sh role-yaml install --features core,cluster,cloudsql > role.yaml
gcloud iam roles create medhook_installer --project "$PROJECT_ID" --file role.yaml

Check it before the first apply

Run the preflight as the identity that will apply, or name it with --member:

bash
PROJECT_ID="$PROJECT_ID" deploy/preflight.sh --iam install --features core,network,cloud-nat,cluster,cloudsql,alerts

It lists every missing permission under its part, with the role that covers it, and exits with an error. If your platform team enables APIs (enable_project_apis = false), it also lists the APIs that are still off, with the command that enables them.

The engine at runtime

SetWhat it is forGranted
classic-vpncreate and delete VPN tunnels and their routes in the chosen VPC, read tunnel trafficunless vpn_mode = "none"
ha-vpnHA VPN peer gateways and BGP sessionswith HA VPN
diagnosticsthe tunnel diagnosis's IKE log, and secret expiry in Settings · Diagnostics (metadata, never values)engine_diagnostics_access
cloudsql-clientonly with the Cloud SQL Auth Proxy; the chart connects over private IPengine_cloudsql_client

On top of those, single-resource grants: write and read on the audit archive bucket (never delete), and whatever optional features add. The engine creates no firewall rules, so it holds no firewall rights. Check the engine's account the same way:

bash
PROJECT_ID="$PROJECT_ID" deploy/preflight.sh --iam runtime --member serviceAccount:<engine service account>

Settings › Resources

Settings › Resources lists what MedHook created in the project with the engine's account, and asks for nothing more: each list the account can't read shows the permission and a read-only role that grants it. Grant those read-only roles only if you want the page to show everything; deploy/inventory.sh lists it all as you either way. See Uninstall and inventory.

Scope the VPN rights in a shared project

By default the engine's VPN role reaches every tunnel and route in the project. Set engine_vpn_scope_condition = true and the rights to create, read and delete a tunnel, route or peer gateway are bound with an IAM condition on this environment's name prefix, the prefix the engine gives everything it creates. Listing, and the gateway and network rights, stay project-wide. Create a test tunnel after you turn it on. A dedicated project, or at least a dedicated VPC, is still the strongest boundary.

Owner is break-glass only

If an apply fails on a permission the lists miss, the preflight output names it; tell your MedHook contact so the list is fixed. A time-boxed roles/owner grant, logged and with a written reason, is the last resort, never the install path.

Reference