# Subnet claims

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


> A CloudIdentity can claim a subnet for its namespace, so no other namespace in the organization places workstations in it.


A CloudIdentity that sets `spec.subnet` places every workstation it selects in that subnet and claims the
subnet for its namespace. No other namespace in the organization can then place a workstation there.

## Effects of a claim

`spec.subnet` names a subnet on GCP, Azure or AWS. It has two effects:

- Every workstation this CloudIdentity selects is placed in that subnet. The value replaces any subnet the
  workstation's own `providerConfig` names.
- The subnet is claimed for this CloudIdentity's namespace. Ringleader refuses a workstation from another
  namespace in the organization that would be placed there when it is applied. That refusal does not name
  the namespace that owns the subnet.

A subnet nobody has claimed stays open to every namespace. Workstations already in a subnet when it is
claimed can still be edited.

A subnet can be claimed by one namespace. A second CloudIdentity that names the same subnet from another
namespace is refused, and that refusal names the namespace that owns it.

## Claims on AWS and Azure

On AWS and Azure, an Edge routes a whole subnet, so a VM that another namespace creates there later loses its
outbound access. [Subnet routing](https://docs.ringleader.dev/security/outbound/edge-management/#subnet-routing) says
why. A claim keeps other namespaces from placing workstations in the subnet.

## Subnets held by another organization

Two organizations may share an AWS account or an Azure subscription, but never a subnet. A VM that
Ringleader builds on AWS or Azure for a namespace in an organization carries a `ringleader-org` tag that
identifies the organization. Just before Ringleader creates a workstation's VM, it reads the VMs in the
workstation's subnet. If one carries another organization's `ringleader-org` tag, Ringleader does not
create the VM.

The workstation stays in `Provisioning`, and its `Ready` condition reads `SubnetHeldByAnotherOrganization`.
Its message names the subnet and nothing about the VM in it. Ringleader checks again every minute and
builds the workstation once that VM has gone.

If Ringleader cannot read the VMs in the subnet, it builds the workstation anyway and sets its
`SubnetUnchecked` condition to `True`. The workstation works normally.

## Claim a subnet

Name the subnet in `spec.subnet` of the CloudIdentity, in its cloud's full form:

- GCP: `projects/<project>/regions/<region>/subnetworks/<name>`, or its self-link URL. Ringleader refuses a
  bare name, because two projects can each have a subnet called `default`.
- Azure: the subnet's full resource id.
- AWS: the `subnet-…` id.

Name the subnet in `spec.subnet` alone. Ringleader refuses a CloudIdentity that also names one in
`defaultProviderConfig` or `overrideProviderConfig`, under `subnetwork` on GCP or `subnetId` on Azure and
AWS:

```text
spec.subnet and spec.defaultProviderConfig.gcp.subnetwork both name a subnet: remove spec.defaultProviderConfig.gcp.subnetwork
```

The namespace must belong to an organization. In a namespace with no organization, Ringleader refuses a
CloudIdentity that sets `spec.subnet`. Name the subnet in the CloudIdentity's `defaultProviderConfig` or
`overrideProviderConfig` there instead.

## Build a workstation that another organization's subnet holds

Name a subnet that your namespace owns, or ask an administrator of your namespace to claim one, as
described in [Claim a subnet](#claim-a-subnet).

## Next steps

- [Subnet ownership](https://docs.ringleader.dev/security/outbound/edge-management/#subnet-ownership):
  how an Edge routes a subnet and what holds that back.
- [Cost allocation labels](https://docs.ringleader.dev/cloud-accounts/cloud-identities/cost-allocation-labels/):
  the other tags Ringleader puts on a workstation's resources.

