# Cloud accounts and reachability

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


> A CloudAccount records which identity Ringleader signs in as in your cloud, and limits who can reach the workstations in that account.


A **CloudAccount** records which identity Ringleader signs in as in one of your cloud accounts, and which setting in your cloud accepts Ringleader's sign-in token. It also decides whether the workstations in that cloud account may have public addresses, and which addresses may open SSH to them.

## CloudAccount and CloudIdentity decisions

A CloudAccount binds one organization to one cloud account. It is not a placement template: it never decides where a workstation runs or how big it is.

Three questions are answered on two objects:

| | Lives on | Example |
|---|---|---|
| **Which cloud identity to use**, meaning which identity Ringleader signs in as and which setting accepts its token | CloudAccount | the target service account, the workload identity provider, the Entra application, the tenant |
| **The VM's size and placement**, meaning what a workstation VM looks like | The [CloudIdentity](https://docs-stg.ringleader.dev/reference/resources/cloudidentity/), in `defaultProviderConfig` and `overrideProviderConfig` | project, zone, machine type, subnet, labels |
| **Who can reach the workstations**, for every workstation in the account | CloudAccount | `allowPublicAddresses`, `sshSourceRanges` |

The [CloudAccount](https://docs-stg.ringleader.dev/reference/resources/cloudaccount/) reference lists the fields, says who can write one and says why it has no namespace.

## Path from a workstation to its CloudAccount

*Diagram: A workstation's labels select a CloudIdentity in its namespace. That identity's spec.cloudAccountRef names a cluster-scoped CloudAccount, which must belong to the organization that owns the namespace. The CloudAccount records which cloud identity to use in your own cloud account, which trusts an assertion whose subject is that organization and nothing else.*

```mermaid
flowchart TB
  WS["<b>Workstation</b><br/>carries labels"]
  CI["<b>CloudIdentity</b> &mdash; namespace <i>dev</i><br/>spec.cloudAccountRef: acme-gcp"]
  CA["<b>CloudAccount</b> &mdash; cluster-scoped<br/>spec.org: acme"]
  Cloud["<b>Your cloud account</b><br/>trusts an assertion whose subject is<br/>organization <i>acme</i> and nothing else"]

  WS -- "selector match" --> CI
  CI -- "must belong to that namespace's org" --> CA
  CA -- "which cloud identity to use" --> Cloud
```


A CloudIdentity points at a CloudAccount by name, in `spec.cloudAccountRef`. The reference must stay inside the CloudIdentity's own organization. Ringleader refuses it when you apply a CloudIdentity that names another organization's account:

```text
apply cloudidentity/gcp: admission: spec.cloudAccountRef names no CloudAccount
in this namespace's org: CloudIdentity dev/gcp references CloudAccount "other-org-gcp"
```

An account that belongs to someone else and an account that does not exist give the same message on purpose. The error then cannot reveal which account names other organizations have. The workstation's namespace must also belong to an organization. If it does not, Ringleader can sign no token for it and refuses the reference for the same reason.

## The two connections a workstation needs

A workstation needs two connections, and they are set up separately:

| | Needs | Provided by |
|---|---|---|
| **Coming up**, meaning it finishes setup and reports `Ready` | a way out, from the VM to Ringleader | a public address, or a NAT gateway |
| **Being used**: `rl shell`, `rl tmux`, port-forwards, VS Code Web | a way in, on TCP 22, from wherever you run `rl` | a firewall rule Ringleader writes, one of your own, or private connectivity |

The network that the onboarding module creates provides the way out. A workstation behind an [Edge](https://docs-stg.ringleader.dev/security/outbound/edge-management/#access-to-a-workstation-behind-an-edge) is reached through a port on the Edge's VM instead of on TCP 22.

A workstation cannot confirm either connection for you. It sets itself up over its own outbound connection, so it reports `Ready` whether or not anything can reach it. Open a shell to check.

## The SSH rule Ringleader writes

Ringleader writes a firewall rule for every workstation it creates. The rule admits SSH on TCP ports 22 and 2222 from any address, unless the CloudAccount lists `sshSourceRanges`. Workstations take a public address by default on all three clouds. With nothing else set, a workstation therefore accepts SSH connections from the internet, and only people with access to the workstation can sign in.

Writing the rule needs the egress control grant, which is on by default. With the grant off, Ringleader cannot write the rule, and the workstation reports the `SSHAdmissionMissing` condition. On AWS, a workstation in a VPC that the grant does not cover reports it too. The workstation still finishes setup and reports `Ready`.

Each cloud applies the rule in its own way:

- **Google Cloud:** Ringleader puts a network tag of its own on every workstation it creates. It writes one VPC firewall rule for VMs with that tag, so the rule does not reach a VM that Ringleader did not create. An ingress deny rule of your own takes precedence if its priority number is `900` or lower. So does a deny in a hierarchical firewall policy.
- **Azure:** Ringleader adds one rule to the network security group (NSG) on the workstation subnet. It admits the ports to the workstations Ringleader creates and to no other VM. The rule takes a priority from 3000 to 3999, so keep that range free in the subnet's NSG. Writing it also needs the actions on application security groups that [Microsoft Azure permissions and resources](https://docs-stg.ringleader.dev/reference/providers/azure-permissions/) lists.
- **AWS:** Ringleader creates a security group of its own in the workstation's VPC and attaches it beside the groups the workstation already has. The group has no outbound rule. EC2 combines every group on an interface, so the group opens the two ports and changes nothing else.

### A rule of your own

The Terraform module and the scripts that you run during onboarding can also write an SSH rule of your own. It admits the addresses your engineers connect from. You set it with `ssh_source_ranges`, or your script's equivalent. It covers TCP 22, and on AWS and Azure TCP 2222 as well.

Your rule applies alongside Ringleader's, so it can let more addresses in and never fewer. It keeps workstations reachable from those addresses when Ringleader cannot write its own rule, for example with egress control turned off. What it covers differs by cloud, and it is wider than Ringleader's workstations:

- **Google Cloud:** every VM that carries the `ringleader-workstation` network tag. Ringleader puts that tag on every workstation that declares no `networkTags` of its own. If a namespace administrator sets `networkTags` on the CloudIdentity, the list must include `ringleader-workstation`.
- **Azure:** every VM on the workstation subnet.
- **AWS:** every instance in the security groups that every workstation is given.

On Azure, a workstation with no egress policy accepts SSH only from the addresses that Ringleader's rule allows. The NSG that Ringleader puts on its network interface allows nothing wider, so your rule does not widen it.

## Public addresses and the way out

A workstation gets a public address by default on all three clouds. A VM with no public address has no route to the internet on its own. It needs an outbound route to Ringleader, such as a NAT gateway (Cloud NAT on Google Cloud), or it never finishes setting up. You then reach it over your VPN, Interconnect, ExpressRoute, Direct Connect or peering.

The onboarding module creates that route, and what it costs differs by cloud:

- **Google Cloud:** the network includes Cloud NAT, so a workstation with no external address still reaches Ringleader.
- **Azure:** the network includes a NAT gateway. The NAT gateway and its public IP bill by the hour whether or not anything uses them. To avoid that, bring your own subnet that already has outbound access, with `create_network = false` or `CREATE_NETWORK=false`. An existing workstation keeps the setting it was created with, so one created while the default was no public IP still has none.
- **AWS:** a public IP gives a workstation outbound access through the internet gateway for free. The network also includes a NAT gateway for workstations without a public IP, and it bills by the hour. If all your workstations will have public IPs, you can pay nothing for it. Set `create_nat_gateway = false` and `create_gateway_subnet = false` (Terraform), or `CREATE_NAT_GATEWAY=false` and `CREATE_GATEWAY_SUBNET=false` (CloudFormation).

Ringleader sets the public address only when it creates the VM, so a later change needs the workstation deleted and created again. A workstation that still carries an address that a newer setting would remove reports the `PublicAddressChangeNotApplied` condition until it is recreated.

## Limit SSH sources

A CloudAccount's `sshSourceRanges` lists the IPv4 ranges that Ringleader's SSH rule admits. With no list, the rule admits any address. The list also limits who can reach the management ports of the account's Edges. Only an organization administrator can change a CloudAccount.

1. Add `sshSourceRanges` to the CloudAccount, with the ranges your engineers connect from:

   ```yaml
   spec:
     org: acme
     provider: gcp
     gcp:
       targetServiceAccount: ringleader-workstations@acme-dev.iam.gserviceaccount.com
       workloadIdentityProvider: projects/123456789/locations/global/workloadIdentityPools/ringleader/providers/oidc
     sshSourceRanges:
       - 203.0.113.0/24
   ```

2. Apply the file with `rl apply -f`. Ringleader then admits only those ranges, for every workstation in the account, including ones created later.

Ringleader refuses an IPv6 range, because the rule is IPv4 only. On Google Cloud and Azure, a change to the list reaches the rules of existing workstations within about 10 minutes. On AWS, it reaches them the next time Ringleader creates or changes a workstation in the same VPC.

## Turn off public addresses

Set `allowPublicAddresses: false` on the CloudAccount to give none of the account's workstations a public address. Ringleader refuses a workstation that asks for one explicitly, with `assignPublicIp: true` on Google Cloud or AWS or `publicIp: true` on Azure. A workstation that does not ask gets no address, even when a CloudIdentity's `overrideProviderConfig` would give it one. With the field absent, each workstation's own setting applies. The field does not apply to Edges.

```yaml
spec:
  org: acme
  provider: aws
  aws:
    targetRoleArn: arn:aws:iam::123456789012:role/ringleader-workstations
  allowPublicAddresses: false
```

<div class="callout callout-warning">
  <p class="callout-title">The setting applies only at creation</p>
  <div class="callout-body">
    Ringleader sets the address only when it creates the VM. Setting <code>allowPublicAddresses: false</code> on an account with running workstations does not remove their addresses. To make an existing workstation private, delete it and create it again, which loses its disk.
  </div>
</div>


To set it for the workstations that one CloudIdentity builds instead, set the public address key in its `defaultProviderConfig` or `overrideProviderConfig`. The key is `assignPublicIp` on Google Cloud and AWS, and `publicIp` on Azure. Use `overrideProviderConfig` when developers must not be able to turn it back on, and `defaultProviderConfig` when they may:

```yaml
spec:
  overrideProviderConfig:
    aws:
      assignPublicIp: false
```

To make a single workstation private, set the same key to `false` in its `providerConfig` when you create it. A workstation with no public address still reaches Ringleader through your NAT gateway.

## Next steps

- [Keyless cloud access](https://docs-stg.ringleader.dev/cloud-accounts/keyless-access/) explains how Ringleader signs in to your cloud with no key.
- [Cloud workstations (GCP, AWS, Azure)](https://docs-stg.ringleader.dev/workstations/providers/cloud/) shows how to create a cloud workstation.
- [Outbound restrictions](https://docs-stg.ringleader.dev/security/outbound/outbound-restrictions/) limits where a workstation may connect, which is the other half of its network access.
- [CloudAccount](https://docs-stg.ringleader.dev/reference/resources/cloudaccount/) lists the fields that this page uses.

