# Storage buckets

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


> Keep a namespace's session transcripts and uploaded files in a bucket in your own Google Cloud, AWS or Azure account.


A **Storage** object tells Ringleader which bucket holds a namespace's files. Those files are the transcripts of agent sessions, files people upload with `rl artifact upload`, and files workstations publish. The bucket lives in your own cloud account, so you decide its location, how long it keeps old data, and which key encrypts it.

[Session transcripts and artifacts](https://docs-stg.ringleader.dev/organizations-teams/transcripts-artifacts/) says what happens to these files with no Storage, and why most teams want transcripts in a bucket they control. [Storage](https://docs-stg.ringleader.dev/reference/resources/storage/) has the fields.

## Requirements

You need three things in place:

- Your organization has connected the cloud account with the artifact storage grant, which is on by default. The artifact storage grant section below says what it allows.
- The namespace has a [CloudIdentity](https://docs-stg.ringleader.dev/reference/resources/cloudidentity/) for that cloud account.
- You are a namespace admin or an organization admin. Members can read a Storage but cannot create or change one, because it decides where everyone's files in the namespace go.

## Artifact storage grant

The artifact storage grant lets Ringleader keep your organization's session transcripts and uploaded files in a bucket or storage account in your own cloud account. The data stays in an account you control. The grant is on by default on all three clouds.

Granting it writes nothing, and it creates no bucket when you apply the onboarding. Ringleader stores files there only after a namespace admin creates a Storage that names the bucket. To turn the grant off, use the setting each cloud section below names. With it off, no Storage can use a bucket in that account, and nothing else changes.

## Managed or named buckets

You choose how to take the grant by whether you name a bucket. A Storage's `grant` field says which you chose:

- **`managed`**: you left the bucket or storage account name empty, so Ringleader may create its own buckets. A Storage that asks Ringleader to create a bucket must be `managed`.
- **`named`**: you named a bucket you created. Set `bucket` to that name. Ringleader gets object access to that bucket and nothing else. It reads and writes objects but never creates, changes or deletes the bucket, so `createBucket`, `versioning` and `bucketDeletionPolicy: DeleteIfEmpty` are refused.

With `named`, the bucket's location, lifecycle rules and encryption key stay yours. Take this one if you have a data-residency or key-custody position to defend.

If your organization's [CloudAccount](https://docs-stg.ringleader.dev/reference/resources/cloudaccount/) declares `artifactStorageBucketPrefix`, the bucket name must also start with that prefix.

To use a bucket you already have, leave out `createBucket` and `location`. Ringleader uses an existing bucket as it is, even with `createBucket: true`, and never counts it as one it created.

## Storage on Google Cloud

On Google Cloud, `bucket` is a Cloud Storage bucket. Ringleader reads its region and encryption from the bucket. The grant cannot widen its own access, and it creates no long-lived keys.

- **Managed:** leave `artifact_storage_bucket` empty. Ringleader can then create buckets named `ringleader-*` when a Storage asks for one. An IAM condition confines the grant to that name pattern, so it reaches no bucket you already have. The bucket name must start with `ringleader-`.
- **Named:** set `artifact_storage_bucket` to a bucket you created.

To turn the grant off, set `enable_artifact_storage = false` in Terraform or `ARTIFACT_STORAGE=0` with gcloud.

## Storage on Microsoft Azure

On Azure, `bucket` is a blob container. You must set `account` to the storage account that holds it, 3 to 24 lowercase letters and digits. Access is by Entra ID and a short-lived token, never a storage key. With `createBucket: true`, Ringleader also creates the storage account when it is missing.

- **Managed:** leave `artifact_storage_account_name` empty. Ringleader can then create its own storage account and containers in the resource group you connected when a Storage asks for them.
- **Named:** set `artifact_storage_account_name` to a storage account you created, and name that account in the Storage's `account` field. Ringleader gets blob access to it and nothing else, with no ability to create, change or delete a storage account.

If you applied this onboarding before 30 October 2026, apply it again before you create a Storage. The earlier version lacks two permissions Ringleader now uses. One hands out short-lived access to a container. The other turns on versioning in a storage account it creates.

To turn the grant off, set `enable_artifact_storage = false` in Terraform, or set the `enableArtifactStorage` template parameter to false (`deploy.sh` passes it through).

## Storage on AWS

On AWS, `bucket` is an S3 bucket. A bucket encrypted with your own KMS key works. For a bucket Ringleader creates, `location` is the region in lower case, such as `eu-west-1`. The grant cannot widen its own access: it has no `s3:PutBucketPolicy` and no ACL writes.

- **Managed:** leave `artifact_storage_bucket` empty. Ringleader can then create buckets named `ringleader-*` when a Storage asks for one. The grant is confined to that name pattern, so it reaches no bucket you already have. The bucket name must start with `ringleader-`.
- **Named:** set `artifact_storage_bucket` to a bucket you created.

If you applied this onboarding before 30 October 2026, apply it again before you create a Storage. The earlier version lacks the bucket versioning and tagging permissions Ringleader now uses, and a Storage names each one that is missing in its status.

To turn the grant off, set `enable_artifact_storage = false` in Terraform or the `EnableArtifactStorage` stack parameter in CloudFormation.

## Bucket names

When Ringleader creates a bucket, the name must be one the cloud accepts. That means 3 to 63 lowercase letters, digits and hyphens, starting and ending with a letter or digit, with no two hyphens in a row. Ringleader refuses a name the cloud would reject before it tries to create anything.

## Folders in a shared bucket

Each namespace writes under its own folder in the bucket: `prefix` followed by the namespace name. With no `prefix`, the folder is the namespace name at the top of the bucket. A `prefix` must end in `/` and must not start with one.

Two namespaces can share a bucket as long as their folders do not overlap. Ringleader refuses a Storage whose folder is the same as, or sits inside, another namespace's folder in the same bucket. Within one namespace, two Storage objects cannot name the same bucket and prefix.

## Several buckets and the default

A namespace can have several Storage objects, in one cloud or across clouds. The **default** takes every file that does not name a Storage:

- A namespace's only Storage is its default, with or without `default: true`.
- With two or more, the one with `default: true` is the default. Only one may carry it.
- With two or more and none marked, a file that names no Storage is refused. Each Storage's `status.message` says the namespace has no default.

Files a workstation publishes always go to the default. A person's upload and an agent session can name another Storage. To choose one for a single upload or session, see [Choose a Storage for one upload or session](https://docs-stg.ringleader.dev/organizations-teams/transcripts-artifacts/#choose-a-storage-for-one-upload-or-session).

## Bucket versioning

For a bucket Ringleader creates, `versioning: true` keeps the old version of an object when it is overwritten or deleted. `noncurrentVersionDays` says how long, 30 days by default, and `0` keeps them forever. For a bucket you created, turn versioning on in the bucket yourself. `status.versioning` reports what the bucket actually does, whoever set it.

## Create a bucket and use it

This Storage asks Ringleader to create a Cloud Storage bucket and send the namespace's files there:

```yaml
apiVersion: core.ringleader.dev/v1
kind: Storage
metadata:
  name: transcripts
  namespace: my-team
spec:
  provider: gcp
  bucket: ringleader-my-team-transcripts
  cloudIdentityRef: gcp           # a CloudIdentity in the same namespace
  grant: managed
  createBucket: true
  location: us-central1
```

Apply it, then check its status:

```sh
rl apply -f storage.yaml
rl describe storage transcripts -n my-team
```

Once `status.reachable` is `true`, every new file in the namespace goes to that bucket. If that is all you need, you are done. The sections below cover switching to a new bucket and deleting a Storage.

## Switch to a new bucket

Ringleader never copies files between buckets. Instead, you point new files at the new bucket and let the old one empty over time:

1. If the old Storage carries `default: true`, change it to `false`.
2. Create a Storage for the new bucket with `default: true`.

When the old Storage is the namespace's only one, it stays the default after step 1, so files keep arriving until step 2. When the namespace has other Storage objects, it has no default between the two steps. A new file that names no Storage is refused until you finish, and a session's transcript waits to be saved.

New files then go to the new bucket. Every earlier file stays readable from the old one, because each file records the bucket it was written to. A session that was already running keeps writing to the bucket it started with until it ends. The old Storage's `status.payloads` counts down as its files reach their retention, and once it reads zero you can delete it.

The bucket, account, prefix, provider, `createBucket` and `location` cannot change after you create a Storage. To change any of them, create a new Storage and switch to it as above.

## Delete a Storage

Ringleader refuses to delete a Storage in two cases, so that no file becomes unreadable:

- **It still holds files.** `status.payloads` shows how many. Wait for them to reach their retention, or delete those artifacts, then try again.
- **An unfinished agent session recorded it.** The refusal names the sessions. Let them finish, then try again.

By default the bucket is kept when you delete its Storage (`bucketDeletionPolicy: Retain`). With `bucketDeletionPolicy: DeleteIfEmpty`, which needs `createBucket: true`, Ringleader also deletes the bucket, but only when all of these hold:

- Ringleader created it for this Storage.
- No other Storage names it.
- It holds no objects, old versions included.

Otherwise the bucket is kept, and an event on the Storage says why. With versioning on, a bucket still holds old versions for `noncurrentVersionDays` after its last file is deleted.

## Next steps

- [Storage](https://docs-stg.ringleader.dev/reference/resources/storage/): the spec and status fields of a Storage.
- [Session transcripts and artifacts](https://docs-stg.ringleader.dev/organizations-teams/transcripts-artifacts/): what Ringleader keeps, and how an upload or a session picks a Storage.
- [Onboard Google Cloud](https://docs-stg.ringleader.dev/guides/onboard-gcp/), [Onboard Microsoft Azure](https://docs-stg.ringleader.dev/guides/onboard-azure/) and [Onboard AWS](https://docs-stg.ringleader.dev/guides/onboard-aws/): connect the cloud account with the artifact storage grant.
- [Policy and OrgPolicy](https://docs-stg.ringleader.dev/reference/resources/policy/): limit which Storage an upload or a session may name.

