Skip to content
Get started

Teams

A workspace hub on GCP

Run a team's workspace hub in a GCP project of its own with the Terraform module, with no public address, reachable only through Tailscale.

The Terraform module runs a team’s workspace hub (wh serve --workspace) on one VM in a GCP project of its own. The VM has no public IP and no ingress rule. Members reach it over Tailscale, which dials out. Start a workspace is how members join once it’s running.

GCP project (its own) your tailnet
┌──────────────────────────────────────┐
│ VPC: no ingress, egress 443 + UDP │
│ ┌──────────────────────────────────┐ │ alex's Mac ───┐
│ │ VM (COS, Shielded, no public IP) │ │ │ HTTPS, Tailscale
│ │ tailscale ── Serve :443 ────────┼─┼───── sam's Mac ────┤ login checked
│ │ │ Tailscale-User-Login │ │ │
│ │ ▼ │ │ dana's Mac ───┘
│ │ wh serve --workspace │ │
│ │ 127.0.0.2:7700 only │ │
│ │ /mnt/disks/wh (data disk) ──────┼─┼── daily snapshots
│ └──────────────────────────────────┘ │
│ Cloud NAT · Artifact Registry · │
│ Secret Manager (Tailscale auth key) │
└──────────────────────────────────────┘

The workspace hub lets a request in by its Tailscale-User-Login header, which Tailscale Serve sets for every caller and strips from what callers send. Anything that could reach the hub’s port without going through Serve could write that header itself. A member key is still needed for everything past the hub’s hello, but the login is the door, so nothing but Serve may ever reach port 7700. The module is built around that:

What Why
No public IP, and no ingress rule at all Nothing on the internet or in the VPC reaches the VM. Members come in over Tailscale, which dials out.
The hub on 127.0.0.2:7700, not 127.0.0.1 Only Serve, running beside it, reaches it. Tailscale in userspace mode forwards tailnet traffic for other ports on to 127.0.0.1, so a hub there would be reachable past Serve. It never forwards to 127.0.0.2.
The hub’s container opens no connections It can’t reach the metadata server for the VM’s token, or anything else.
Serve’s config turns Funnel off The hub is never on the public internet, even if someone grants Funnel to its tag.
A tagged Tailscale node (tag:wheelhouse-workspace) It belongs to no person, its key doesn’t expire, and the tailnet policy says exactly who reaches it: members, on 443. The policy’s tests refuse a change that would open port 7700.
  • A VPC of its own, one small subnet with Private Google Access and flow logs, and Cloud NAT to get out. Ingress is denied and logged. Egress is limited to TCP 443 and UDP for Tailscale (restrict_egress).
  • One VM on Container-Optimized OS: Shielded (secure boot, vTPM, integrity monitoring), OS Login only, no project-wide SSH keys, no serial port, and COS’s own automatic updates.
  • Two containers, each read-only, with every capability dropped, no-new-privileges, and memory and process limits: tailscale in userspace mode, publishing the hub at https://NAME.TAILNET.ts.net, and the hub itself, by digest. The hub’s image is a static wh on distroless, as a non-root user.
  • A data disk, apart from the VM: the member log, every shared docket, the files they name, and Tailscale’s node key. Snapshotted daily and kept 14 days. Terraform refuses to destroy it. The VM can be replaced at any time without losing the workspace or its tailnet name.
  • A service account for the VM that writes logs and metrics, reads one image repository and one secret, and nothing else.
  • An Artifact Registry repository whose tags can’t be moved once pushed.
  • A Secret Manager secret for the Tailscale auth key. Terraform makes the secret but never its value, so the key is never in a plan or the state.
  • SSH through IAP only, for the people in ssh_members, on this one VM.
  • Optional CMEK (kms_key) for the boot and data disks.

It doesn’t make alerting, a GKE or Cloud Run variant, or anything for the members’ own hubs: those stay on their Macs.

Use groups everywhere, so people come and go without an apply.

Who What they hold What they need
Operators (group:wheelhouse-ops) The Terraform, the image, SSH to the VM A role on the project that can make these resources and set their IAM (Owner is simplest, on a project of its own), and access to the state bucket
A tailnet admin The tailnet policy, and the auth key Tailscale admin. In GCP, only adding a version to the one secret, or an operator does it for them.
Workspace admins Who’s in the workspace (wh team invite, role, remove) An admin role in the workspace. No GCP access at all.
Members Their own Mac’s hub To be in group:wheelhouse on the tailnet and in the workspace. No GCP access at all.
  • A GCP project for it alone, with billing. It keeps the IAM small and the blast radius smaller.
  • On the operator’s machine: gcloud (signed in), Terraform 1.7 or later, Docker with buildx, and a checkout of the repo.
  • The tailnet: MagicDNS and HTTPS certificates on (Tailscale admin console, DNS). Then merge the module’s tailscale-policy.hujson into your policy file: group:wheelhouse with each member’s login, the tag owned by admins, one grant to tcp:443 on the tag, and tests that fail if anything opens more.
  • Take out or narrow the default rule that lets everyone reach everything. The hub stays safe without that, but Tailscale forwards every other port to the VM’s loopback, so the whole tailnet could reach the VM’s SSH server, past IAP and its audit log. The policy’s tests fail until it’s gone.
  • Organization policies: the module already satisfies the usual ones (no external IPs, OS Login required, Shielded VM required, restricted regions).
  1. Configure.

    Terminal window
    cp -R examples/workspace/gcp/example ~/wheelhouse-gcp # or into your infra repo
    cd ~/wheelhouse-gcp
    cp terraform.tfvars.example terraform.tfvars # project, region, groups

    Point source in main.tf at the module where you keep it (a path, or the repo by git URL and commit). Keep the state in a bucket the operators share: backend.tf.example has the commands. Two operators must never apply from two copies of it.

    terraform.tfvars sets only what the example passes to the module: project_id, region, zone, image, ssh_members, image_publishers and kms_key. The module takes more (variables.tf). To set one, put it in the module "workspace" block in main.tf, where it takes effect; in terraform.tfvars, Terraform only warns and ignores it:

    module "workspace" {
    # …what's there…
    machine_type = "c4a-standard-1"
    cloud_logging = false
    }
  2. First apply: everything but the VM. With image left out:

    Terminal window
    terraform init
    terraform apply

    This turns the APIs on and makes the network, the repository, the secret, the service account and the data disk.

  3. Add the Tailscale auth key. In the Tailscale admin console, Settings → Keys → Generate auth key: reusable off, expiring in 1 day, ephemeral off, pre-approved on if your tailnet approves devices, and tagged tag:wheelhouse-workspace. Then add it as the secret’s version without it touching your shell history or Terraform:

    Terminal window
    read -rs TS_AUTHKEY && export TS_AUTHKEY # paste, Enter
    eval "$(terraform output -raw add_tailscale_auth_key)"
    unset TS_AUTHKEY
  4. Build and push the image, from the repo’s root, at the commit the team’s Macs run:

    Terminal window
    REPO=$(terraform -chdir="$HOME/wheelhouse-gcp" output -raw image_repository)
    TAG=$(git rev-parse --short HEAD)-amd64 # tags can't move: one per commit and platform
    gcloud auth configure-docker "${REPO%%/*}"
    docker buildx build --platform linux/amd64 -f examples/workspace/Dockerfile -t "$REPO:$TAG" --push .
    gcloud artifacts docker images describe "$REPO:$TAG" --format 'value(image_summary.fully_qualified_digest)'

    The last line prints the image by digest. On an Apple silicon Mac, an amd64 build runs under emulation and takes a while. An Arm machine_type in the module "workspace" block (c4a-standard-1, or t2a-standard-1 where it’s offered) lets you build --platform linux/arm64 natively instead (tag it …-arm64).

  5. Second apply: the VM. Set image in terraform.tfvars to that digest, then terraform apply. On its first boot the VM formats the data disk, logs Tailscale in with the key, and starts the hub. In a minute or two, Tailscale’s Machines page shows wheelhouse-workspace, tagged, and from a member’s Mac:

    Terminal window
    curl https://wheelhouse-workspace.TAILNET.ts.net/team/v1/hello # {"workspace":false}
  6. Make the workspace, now. Read the setup code one of two ways:

    Terminal window
    eval "$(terraform output -raw setup_code_command)" # through IAP (ssh_members)
    eval "$(terraform output -raw setup_code_from_logs)" # from Cloud Logging

    Then, on the first admin’s Mac:

    Terminal window
    wh team create Acme --prefix ACME --url https://wheelhouse-workspace.TAILNET.ts.net --setup whs1.…
    wh team members # you, as its only admin

    If wh team create says the hub has a workspace already, someone made it first: don’t use it. Wipe it and start again (see Retiring it).

  7. Destroy the auth key’s version. It’s spent, and the VM doesn’t need it again:

    Terminal window
    S=$(terraform output -raw tailscale_auth_key_secret) # projects/P/secrets/NAME
    for v in $(gcloud secrets versions list "$S" --filter state=enabled --format 'value(name.basename())'); do
    gcloud secrets versions destroy "$v" --secret "$S" --quiet
    done

    Then invite the team: Start a workspace.

  • Joining: a tailnet admin adds their login to group:wheelhouse; a workspace admin runs wh team invite HANDLE and hands them the code; they run wh team join on their Mac.
  • Leaving: a workspace admin runs wh team remove HANDLE first. That revokes every key they had, on every hub, from then on; what they signed before still verifies. Then take them out of group:wheelhouse.
  • A lost or stolen Mac: both of the above, at once, and remove the device in Tailscale. The person rejoins from a new Mac with a new invite and new keys.
  • Operators leaving: take them out of the ops group. Nothing on the VM is theirs.

Take a snapshot first:

Terminal window
gcloud compute disks snapshot wheelhouse-workspace-data --zone ZONE --snapshot-names wheelhouse-pre-upgrade-$(date +%Y%m%d)
  • Wheelhouse: build and push the new commit (step 4), set image to its digest, and terraform apply. The plan replaces the VM and keeps the data disk and the tailnet name. The hub is gone for a minute or two; members’ hubs keep their writes in their outboxes and send them when it’s back.
  • Tailscale: set tailscale_image in the module "workspace" block to a newer digest, and apply.
  • COS: it updates itself, and an update takes effect at the next reboot: gcloud compute instances reset wheelhouse-workspace --zone ZONE at a quiet moment.

The data disk is snapshotted daily and kept for snapshot_retention_days (14), in the region.

To restore:

Terminal window
terraform state rm module.workspace.google_compute_disk.data # the old disk stays, untracked
# in main.tf's module "workspace" block (not terraform.tfvars, which ignores them):
# data_disk_name = "wheelhouse-workspace-data-r1"
# data_disk_snapshot = "projects/PROJECT/global/snapshots/SNAPSHOT"
terraform apply # a new disk, and a new VM on it

Delete the old disk once you’re sure you don’t need it.

  • Is it up? wh team on any member’s Mac says connected or not. The module adds no alerting; a log-based alert on wh-workspace.service failing is the place to start.
  • Logs: in Cloud Logging under the VM, or over SSH: sudo journalctl -u wh-workspace -u wh-tailscale -u wh-data.
  • The boot: each boot, the VM checks and mounts the data disk, reads the auth key, pulls the image by digest and starts the hub. If a step fails, it tries again every 10 seconds, and the journal says why. A disk is formatted only when it’s new; one that can’t be read is left alone for you to repair.
  • Cost: in us-central1 at list prices, an e2-small, its disks, Cloud NAT and the snapshots come to roughly $20 a month.

The data disk outlives terraform destroy on purpose. To remove everything:

Terminal window
terraform state rm module.workspace.google_compute_disk.data
terraform destroy
gcloud compute disks delete wheelhouse-workspace-data --zone ZONE
gcloud compute snapshots list --filter 'labels.app=wheelhouse-workspace' # then delete them

Then remove the machine in Tailscale. Members’ hubs keep their copies of every shared docket, and wh verify still checks them.

Who Can Can’t
Anyone on the internet Nothing Reach the VM: no public IP, no ingress, Funnel off
Anything else in the project’s network Nothing Reach the VM, or the hub’s port
Someone on the tailnet, not in the group Nothing Reach the node: the policy grants only group:wheelhouse
A member What a member can on any workspace (How teams work) Reach anything on the VM but the hub, through Serve
An operator Read what’s shared, stop the hub, run another image, read the setup code Forge an entry, add a member, or rewrite what members’ hubs have without them noticing
A project log reader, before the workspace is made Read the setup code, and make the workspace if they’re also in the group Anything once it’s made: the code is gone
A tailnet admin Add themselves to the group, put a node on the tag Get past the member key: every request and entry is signed

What it doesn’t do yet:

  • The setup code reaches the logs. COS sends the containers’ output to Cloud Logging (cloud_logging = false in the module "workspace" block stops that, and the rest of the logs with it). Make the workspace right after the first boot, and check wh team members says it’s yours.
  • What’s shared isn’t encrypted against the operators. It’s on the disk in the clear, encrypted at rest by Google or your key.
  • No alerting, and no high availability: one VM, one zone. Members’ outboxes ride out an outage; a lost zone means a restore.