# CloudAccount

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


> Which cloud identity Ringleader uses for one organization and one cloud account, which namespaces may use it, and the limits on how that account's workstations can be reached.


A **CloudAccount** binds **one organization** to **one cloud account**. It defines
which cloud identity to use: which identity Ringleader signs in as in your cloud, and which
setting in your cloud accepts Ringleader's sign-in token. It can also limit two things:

- Which of the organization's namespaces may use the account.
- How the workstations in the account are reached: whether they may have public addresses, and
  which addresses may open SSH to them.

```text
apiVersion: core.ringleader.dev/v1
kind: CloudAccount
```

It is **cluster-scoped** (it has no `metadata.namespace`) because a cloud account
belongs to an organization, which spans namespaces. A
[CloudIdentity](https://docs-stg.ringleader.dev/reference/resources/cloudidentity/) points at one by name
(`spec.cloudAccountRef`) to get its credentials through it.

The [Cloud accounts and reachability](https://docs-stg.ringleader.dev/cloud-accounts/accounts-reachability/) page explains what a CloudAccount decides, how a workstation reaches it and who can reach the workstations in it. [Keyless cloud access](https://docs-stg.ringleader.dev/cloud-accounts/keyless-access/) explains why it holds no secret.

## Authors
A CloudAccount is **org-owned infrastructure**, not a tenant object:

- **Organization administrators** may create, read, update, and delete the
  CloudAccounts of **their own organization**. Ringleader enforces that on
  both the incoming object and the stored one, so an account cannot be re-homed to
  another organization by editing it.
- **Ringleader operators** (global admins) may write any organization's.
- **A namespace member holds no permission on this kind at all**, not even read.
  This choice of cloud identity is therefore outside the surface a normal user can
  write, which is the entire point.

## Examples

### Google Cloud

```yaml
apiVersion: core.ringleader.dev/v1
kind: CloudAccount
metadata:
  name: acme-gcp
spec:
  org: acme
  provider: gcp
  gcp:
    # The service account in YOUR project that Ringleader acts as. It holds the
    # workstation permissions; Ringleader's token impersonates it directly.
    targetServiceAccount: ringleader-workstations@acme-dev.iam.gserviceaccount.com
    # YOUR workload identity provider's resource name. This is the token-exchange
    # audience, NOT the assertion's `aud` claim (see Keyless cloud access).
    workloadIdentityProvider: projects/123456789/locations/global/workloadIdentityPools/ringleader/providers/oidc
```

Apply it before the CloudIdentity that references it (a multi-document `apply`
orders them for you):

```bash
rl apply -f acme-gcp-account.yaml
rl cloudaccount get        # alias: rl ca get
```

### Microsoft Azure

```yaml
apiVersion: core.ringleader.dev/v1
kind: CloudAccount
metadata:
  name: acme-azure
spec:
  org: acme
  provider: azure
  azure:
    # The Entra application (client) id that holds the workstation permissions on
    # your resource group, and whose federated identity credential trusts
    # Ringleader's per-organization issuer.
    targetAppClientId: ec6d0a82-536f-463e-baa5-a10221befa86
    # Your Azure AD tenant.
    tenant: bb90f2d3-842d-41ea-8c0c-0e6671775ef7
```

### AWS

```yaml
apiVersion: core.ringleader.dev/v1
kind: CloudAccount
metadata:
  name: acme-aws
spec:
  org: acme
  provider: aws
  aws:
    # The IAM role in YOUR account that Ringleader assumes via
    # AssumeRoleWithWebIdentity. Its trust policy admits only your organization's
    # subject and audience. This one value is all AWS needs to sign in. AWS finds the
    # OIDC provider and the audience from the signed token itself.
    targetRoleArn: arn:aws:iam::123456789012:role/ringleader-workstations
```

## Spec fields

| Field | Type | Description |
|-------|------|-------------|
| `org` | `string` | **Required.** The [organization](https://docs-stg.ringleader.dev/reference/resources/organization/) that owns this cloud account. It must be the organization the referencing CloudIdentity's namespace belongs to. |
| `provider` | `string` | **Required.** `gcp`, `azure` or `aws`. |
| `gcp.targetServiceAccount` | `string` | **Required for `gcp`.** The service account in your project that Ringleader acts as. A bare email, or a fully qualified `projects/…/serviceAccounts/…` resource name. |
| `gcp.workloadIdentityProvider` | `string` | **Required for `gcp`.** Your workload identity provider's resource name, `projects/<number>/locations/global/workloadIdentityPools/<pool>/providers/<provider>`. An `//iam.googleapis.com/` prefix is accepted and optional. |
| `gcp.targetScope` | `string` | Optional OAuth scope override for the access token (default: cloud-platform). |
| `azure.targetAppClientId` | `string` | **Required for `azure`.** The Entra application (client) id Ringleader authenticates as. |
| `azure.tenant` | `string` | **Required for `azure`.** Your Azure AD tenant id. |
| `aws.targetRoleArn` | `string` | **Required for `aws`.** The IAM role Ringleader assumes via `AssumeRoleWithWebIdentity`. It is the only AWS value that signing in needs. AWS finds the identity provider from the token's `iss` and checks `aud` against that provider's client-id list, so neither is named here. There is no `aws.targetScope`. |
| `aws.workstationIdentityPath` | `string` | The IAM path under which your onboarding setup lets Ringleader create workstation roles and instance profiles: `/ringleader-workstations/` on Terraform and `/ringleader/` on CloudFormation, unless you set your own. Ringleader needs it to give an AWS workstation a [runtime identity](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/runtime-identities/) declared in `spec.serviceAccount`. It is `/`, or a path that starts and ends with `/`. |
| `azure.targetScope` | `string` | Optional OAuth scope override (default: the Azure Resource Manager `.default` scope). |
| `allowedNamespaces` | `[]string` | The namespaces of the organization that may use this account. Leave it out to allow every namespace. An empty list is refused. See [Namespaces that may use an account](#namespaces-that-may-use-an-account). |
| `allowPublicAddresses` | `bool` | `false` keeps every workstation in this account off public addresses. See [Turn off public addresses](https://docs-stg.ringleader.dev/cloud-accounts/accounts-reachability/#turn-off-public-addresses). |
| `sshSourceRanges` | `[]string` | IPv4 ranges allowed to open SSH to this account's workstations. Default: any address. See [Limit SSH sources](https://docs-stg.ringleader.dev/cloud-accounts/accounts-reachability/#limit-ssh-sources). |

A `gcp` account may not carry an `azure` block, and vice versa. An incomplete
configuration is refused when you apply it, not when a workstation later fails to boot:

```text
apply cloudaccount/acme-gcp: validation failed:
spec.gcp.workloadIdentityProvider: is required
```

## Namespaces that may use an account

Any namespace of the organization can use a CloudAccount unless the account lists the ones that
may. List them in `allowedNamespaces` to keep an account, such as your production one, to the
teams that need it:

```yaml
spec:
  org: acme
  provider: gcp
  allowedNamespaces: [platform, payments]
```

To allow every namespace again, remove the field. That is the only way to allow them all, because
Ringleader refuses an empty list:

```text
spec.allowedNamespaces: is empty: list at least one namespace, or remove the field to allow every namespace
```

A name you list does not have to exist yet, so you can list a namespace before you create it.
Ringleader checks only that each entry is a valid namespace name. A name that belongs to another
organization allows nothing.

In a namespace that is not on the list:

- **A CloudIdentity** that names the account is refused when you create it, or when you change its
  `cloudAccountRef` to the account. The message is the one for an account that does not exist, so
  it does not reveal which accounts your organization has. You can still edit a CloudIdentity that
  already names the account.
- **A new workstation** skips a CloudIdentity whose account does not allow the namespace.
  Its `status.cloudIdentitySkipped` names the ones it skipped. If no other CloudIdentity selects
  the workstation, Ringleader refuses it.
- **An existing workstation** built through the account gives the reason in its `status.message`.
  Ringleader does not start it, and does not move it to another CloudIdentity.
- **An Edge** gives the reason in its `status.message`.
- **A Storage** reads `reachable: false` in its status, with the reason in `message`.

The reason names the account and the namespace, so an organization administrator knows what to add:

```text
CloudAccount "acme-prod" does not allow namespace "web" to use it. An org admin can add the namespace to the account's spec.allowedNamespaces
```

You can still delete a workstation, an Edge or a Storage that the namespace already built.

Ringleader refuses a change to the list, or a delete of the account, that would make the disk of an
existing workstation smaller. This can happen only to a workstation that an earlier release created
without recording its CloudIdentity, because Ringleader chooses one for it again. The message names
the workstation and says what to do.

<div class="callout callout-warning">
  <p class="callout-title">Stop workstations before you remove a namespace</p>
  <div class="callout-body">
    A workstation that is running when its namespace leaves the list keeps running, and your cloud keeps
billing for it. Ringleader cannot stop it until the namespace is back on the list. It can only
delete it.
  </div>
</div>


## Status fields

The system writes these. They answer one question: **can a workstation governed by
this account actually get a cloud credential?**

| Field | Type | Description |
|-------|------|-------------|
| `message` | `string` | The headline: `the account is ready: its org's OIDC issuer documents are published`, or `the account is not ready, so a workstation governed by it cannot mint a cloud credential`. |
| `oidc.ready` | `bool` | Whether the federation is usable end to end. |
| `oidc.message` | `string` | The specific reason when it is not. This is the one to read. |

```bash
rl cloudaccount get acme-gcp -o jsonpath='{.status.oidc.message}{"\n"}'
```

`oidc.ready` is derived from the account's own validity **and** its org's publish
state, so a healthy account whose org has not published yet reports not-ready and
says which of the two is the problem, e.g.:

```text
org acme's OIDC issuer documents are not published yet, so a cloud cannot validate
an assertion for it
```

The account's own failures read the same way: `the account names no org, so no
assertion can be signed for it`, `org acme does not exist`, or the validator's own
text when the spec is invalid.

<div class="callout callout-note">
  <p class="callout-title">Why AWS needs a single field</p>
  <div class="callout-body">
    <p>The AWS configuration is <strong>one field</strong>. Unlike the other two clouds, an
<code>sts:AssumeRoleWithWebIdentity</code> request names neither an audience nor an identity
provider. AWS finds the provider from the token&rsquo;s own <code>iss</code>, and checks the <code>aud</code> claim
against that provider&rsquo;s client-id list. Both checks therefore live inside the signed token
and in your own IAM configuration, so the account carries only the role to assume.</p>
<p>See <a href="https://docs-stg.ringleader.dev/guides/onboard-aws/">Onboard AWS</a> to set it up.</p>

  </div>
</div>


## Next steps
- [Cloud accounts and reachability](https://docs-stg.ringleader.dev/cloud-accounts/accounts-reachability/): what a CloudAccount decides, how a workstation reaches it and who can reach the workstations in it.
- [Keyless cloud access](https://docs-stg.ringleader.dev/cloud-accounts/keyless-access/): why Ringleader holds no key, and the values your cloud checks.
- [CloudIdentity](https://docs-stg.ringleader.dev/reference/resources/cloudidentity/): the namespaced object that references a CloudAccount and shapes the workstations it builds.

