# Google Cloud permissions and resources

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> What onboarding creates in your Google Cloud project, the roles and permissions it grants Ringleader, and what your project checks.


Onboarding Google Cloud creates a small set of resources in your project and grants
Ringleader a fixed set of roles on them. This page lists each of them.
[Onboard Google Cloud](https://docs-stg.ringleader.dev/guides/onboard-gcp/) shows how to create them.

## Resources onboarding creates

*Diagram: Ringleader signs a short-lived OIDC token whose issuer and subject name your organization, and presents it to a Workload Identity Pool and OIDC provider in your own Google Cloud project. That provider admits only your organization's subject and audience, and impersonation bound to that one subject reaches the ringleader-workstations service account you create, which holds compute.instanceAdmin.v1, compute.networkUser and iam.serviceAccountUser. That service account creates, manages and deletes the workstation VMs in your project.*

```mermaid
flowchart TB
  CP["<b>Ringleader control plane</b><br/>signs a short-lived OIDC token<br/>iss = &lt;issuer&gt;/org/&lt;your-org-id&gt;<br/>sub = org:&lt;your-org-id&gt;"]

  subgraph project["Your Google Cloud project"]
    direction TB
    Pool["<b>Workload Identity Pool + OIDC provider</b><br/>admits only your organization's subject,<br/>and only the per-org audience"]
    SA["<b>ringleader-workstations@&lt;your-project&gt;</b><br/>the service account you create<br/>compute.instanceAdmin.v1 + compute.networkUser"]
    VMs["<b>Workstation VMs</b><br/>created, managed and deleted"]
  end

  CP -- "presents the token" --> Pool
  Pool -- "impersonation bound to that one subject" --> SA
  SA --> VMs
```


Onboarding creates four things in your project, and you can see all of them in the
Google Cloud console afterwards:

- A **service account** called `ringleader-workstations`. This is the account
  Ringleader uses when it creates or deletes a VM.
- **Three roles and one custom role** granted to that account. Together they let it
  create, start, stop and delete VMs, connect them to your network, and create service
  accounts for the VMs it runs, and nothing else.
- A **workload identity pool** with one provider. This is how Google confirms that a
  request really comes from Ringleader and is meant for your organization, without
  Ringleader ever holding a password or a key.
- A **network** for the workstations: a VPC, a subnet, Cloud NAT and firewall rules.
  Terraform creates this unless you set `create_network = false`. On the gcloud path
  it is a separate script you run only if you want it.

## Rights and limits in your project

The service account holds three predefined roles and one custom role: no Owner, no Editor
and nothing in billing. [Cloud accounts](https://docs-stg.ringleader.dev/cloud-accounts/) says what
Ringleader gets and what it never gets.

Three features are on by default and add to this:
[Cloud runtime identities](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/runtime-identities/),
[Egress control permissions](#egress-control-permissions) and
[Storage buckets](https://docs-stg.ringleader.dev/cloud-accounts/storage-buckets/).

## Roles

The service account holds these roles:

- `roles/compute.instanceAdmin.v1`: create, start, stop and delete VMs and their
  disks.
- `roles/compute.networkUser`: attach a VM to your subnet.
- `roles/iam.serviceAccountUser`: attach a service account to a VM. Every VM on Google
  Cloud runs as a service account, and attaching one is a separate permission that the
  two roles above do not include. Without it, creating the first workstation fails
  with a `403` error.
- A custom role, `Ringleader Managed Identities`: create and delete service accounts,
  and nothing else. A VM on Google Cloud cannot start without a service account, so
  Ringleader creates one account with no roles, `rl-box-noroles`, for the VMs that name
  none. This role cannot grant any role, so that account can do nothing in your project.

[Runtime identity roles](#runtime-identity-roles) lists the two further roles that
per-user runtime identities need.

## Runtime identity roles

Creating and binding the per-user service accounts that
[Cloud runtime identities](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/runtime-identities/)
describes takes two more roles than the ones above:

| Capability | Role it needs |
|---|---|
| Create and delete the per-user service account | `roles/iam.serviceAccountAdmin` |
| Bind roles to it on the project | `roles/resourcemanager.projectIamAdmin` |
| Attach it to a VM | `roles/iam.serviceAccountUser`, already granted above |

## Checks your project makes

When Ringleader asks to act in your project, Google checks three things about the
token it presents. All three are built from the two values Ringleader gave you, and
the module and the script configure them, so you never type them yourself.

| What Google checks | Value | Where it is configured |
|---|---|---|
| Who signed the token | `<issuer-url>/org/<org-id>` | the provider's `issuer_uri` |
| Which organization it speaks for | `org:<org-id>` | the provider's `attribute_condition` |
| Which cloud it may be used against | `<issuer-url>/org/<org-id>/gcp` | the provider's `allowed_audiences` |

[Keyless cloud access](https://docs-stg.ringleader.dev/cloud-accounts/keyless-access/) says what each value
means. Who may use the `ringleader-workstations` service account is a fourth check. It
should be your organization alone, written `principal://…/subject/org:<org-id>`, and never
`principalSet://…/workloadIdentityPools/<pool>/*`.

## Egress control permissions

Egress control grants a **custom project role** with fourteen permissions and nothing
else:

| Permissions | For |
|---|---|
| `compute.firewalls.create` / `delete` / `get` / `list` / `update` | create and maintain the firewall rules that carry each policy, and the rule that admits SSH to your workstations |
| `compute.routes.create` / `delete` / `get` / `list` | the static route that sends traffic to the edge instance, for a policy that names hostnames rather than address ranges |
| `compute.networks.updatePolicy` | creating that route additionally requires it |
| `compute.addresses.create` / `delete` / `get` / `list` | reserving a fixed address for the edge instance. Ringleader does not use them today: the edge instance's public address is not reserved, so it changes when Ringleader replaces the VM |

Each distinct policy becomes **one** set of firewall rules, matched by network tag, so a
hundred workstations sharing a policy cost one set of rules rather than a hundred.
[Enforcement points](https://docs-stg.ringleader.dev/security/outbound/enforcement/) says which of your own
firewall rules can defeat a policy.

## Setup switches

Both setup tools turn a default off with one setting. Each default is on until you set it.

| Default | Terraform | gcloud |
|---|---|---|
| Egress control | `enable_egress_control = false` | `EGRESS_CONTROL=0` |
| Runtime identities | `enable_workstation_identities = false` | `WORKSTATION_IDENTITIES=0` |
| Artifact storage | `enable_artifact_storage = false` | `ARTIFACT_STORAGE=0` |
| The network | `create_network = false` | a separate script, `network-landing-pad.sh`, that you run only if you want it |

With egress control off, workstations are reachable only through a rule of your own. With
artifact storage off, no Storage can use a bucket in this project, and nothing else changes.
[Turn off runtime identities](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/runtime-identities/#turn-off-runtime-identities)
says what the third switch does.
The Terraform variable `artifact_storage_bucket` names one bucket you created; leave it empty
to let Ringleader create its own.

## Values you hand back

| Value | Where it lands |
|---|---|
| **target service account email** | [CloudAccount](https://docs-stg.ringleader.dev/reference/resources/cloudaccount/) `spec.gcp.targetServiceAccount` |
| **workload identity provider** (the resource name) | `spec.gcp.workloadIdentityProvider` |
| **project id** | [CloudIdentity](https://docs-stg.ringleader.dev/reference/resources/cloudidentity/) `providerConfig.gcp.project` |
| **subnetwork self-link** (only if you created a network) | `providerConfig.gcp.subnetwork` |

`terraform output handoff` prints all of these together, and the gcloud path prints
them when `./onboard.sh` finishes.

## Next steps

- [Onboard Google Cloud](https://docs-stg.ringleader.dev/guides/onboard-gcp/): create these resources and hand the values back.
- [Cloud accounts](https://docs-stg.ringleader.dev/cloud-accounts/): what a CloudAccount is and how Ringleader uses your project.

