# S3 storage

> This document describes current S3 support in Floe.

Source: https://openlakeforge.dev/floe/storages/s3/

This document describes current S3 support in Floe.

## Requirements

Floe uses the standard AWS credential/provider chain. Configure access using
the usual environment variables, for example:

- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`
- `AWS_SESSION_TOKEN` (if using temporary credentials)
- `AWS_REGION` or `AWS_DEFAULT_REGION`

## Config example

```yaml
storages:
  default: local
  definitions:
    - name: local
      type: local
    - name: s3_raw
      type: s3
      bucket: my-bucket
      region: eu-west-1
      prefix: raw/data

entities:
  - name: customers
    source:
      format: json
      options:
        json_mode: array
      path: inbound/customers
      storage: s3_raw
    sink:
      accepted:
        format: parquet
        path: outbound/customers
        storage: s3_raw
      rejected:
        format: csv
        path: outbound/customers_rejected
        storage: s3_raw
    policy:
      severity: reject
    schema:
      columns:
        - name: customer_id
          type: string
```

Resolved S3 URIs are formed as:

```
s3://<bucket>/<prefix>/<path>
```

## Supported behavior

- Inputs: CSV, TSV, JSON (array/ndjson), ORC, Parquet, XLSX, Avro, and XML via prefix listing + suffix filtering.
- Outputs:
  - Accepted parquet: each part is built in memory, then uploaded.
  - Accepted Iceberg: PyIceberg (and DuckDB for merges) write the table files directly.
  - Accepted Delta: delta-rs writes the table files directly (see [Delta sink](https://openlakeforge.dev/floe/sinks/delta/)).
  - Rejected CSV and Parquet: built in memory, then uploaded; rejected Iceberg is a quarantine table.
  - Reports: JSON uploaded.

## Limitations

- Source path is treated as a prefix. A glob in the path (`*`, `?`) is matched against the
  listed keys and needs a non-empty literal prefix before the first wildcard.
- Only suffix filtering by format is applied (e.g., `.csv`, `.tsv`, `.json`, `.jsonl`, `.orc`, `.xlsx`, `.avro`, `.xml`).
- Recursive listing behavior is not configurable yet (S3 prefix lists are
  effectively recursive).
- Parquet/ORC input uses temp download + local read.

## S3-compatible providers

`type: s3` also reaches any store that speaks the S3 API. Point it at the provider with these fields:

| Field | Meaning |
|---|---|
| `endpoint` | The provider's S3 URL, e.g. `https://s3.fr-par.scw.cloud` |
| `region` | The provider's region name, e.g. `fr-par` (Scaleway) or `gra` (OVHcloud) |
| `path_style_access` | `true` for `https://<endpoint>/<bucket>/<key>`, `false` for `https://<bucket>.<endpoint>/<key>`. Unset keeps the client default; `AWS_S3_FORCE_PATH_STYLE=1` sets it from the environment |

Credentials are the usual `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`; they are never read from the config.

```yaml
storages:
  definitions:
    - name: lake
      type: s3
      bucket: my-bucket
      region: fr-par
      endpoint: https://s3.fr-par.scw.cloud   # Scaleway; OVHcloud: https://s3.gra.io.cloud.ovh.net
      path_style_access: true
```

Provider endpoints, as given in the verification issues (#1269, #1270):

| Provider | Endpoint example |
|---|---|
| Scaleway Object Storage | `https://s3.fr-par.scw.cloud` |
| OVHcloud Object Storage (S3-API offer) | `https://s3.gra.io.cloud.ovh.net` |

What has been verified per provider is in the [support matrix](https://openlakeforge.dev/floe/reference/support-matrix/#s3-compatible-providers).

> **Warning: conditional writes.** `incremental_mode: file` keeps its state with conditional writes
> (`If-None-Match: *` and `If-Match`). A provider that ignores those headers instead of refusing them lets two
> concurrent runs claim the same files and ingest them twice, with no error. Running concurrent
> `incremental_mode: file` runs against a provider is only safe if it enforces conditional writes. Check it
> before relying on it (see below). Scaleway and OVHcloud enforce them (verified 2026-11-23, #1269, #1270).

### Provider notes

**Scaleway Object Storage** (verified on `fr-par`, `https://s3.fr-par.scw.cloud`, region `fr-par`):

- Path-style and virtual-hosted addressing both work.
- Use the access key and secret key of a Scaleway API key with Object Storage permissions as `AWS_ACCESS_KEY_ID`
  and `AWS_SECRET_ACCESS_KEY`.
- Floe v0.10.4 and earlier: when two `incremental_mode: file` runs of one entity collide on the state write, the
  one that loses can fail with `storage_error` (`s3 get object failed: ... MethodNotAllowed`) instead of retrying,
  while the entity's state is small (#1432). It fails closed: nothing is ingested twice. Fixed in v1.0.0.

**OVHcloud Object Storage** (the Public Cloud S3-API offer, verified on `GRA`, `https://s3.gra.io.cloud.ovh.net`,
region `gra`):

- Path-style and virtual-hosted addressing both work.
- Credentials are the S3 credentials of a Public Cloud user (*Users & Roles*, role *ObjectStore operator*).
  That role alone gets `AccessDenied` on a bucket another identity created: also give the user read and write
  on the bucket (*Object Storage* → the bucket → *Users*).
- Floe v0.10.4 and earlier: Iceberg sinks fail at `load_table` and commit with
  `Value for x-amz-checksum-mode header is invalid`; set `AWS_RESPONSE_CHECKSUM_VALIDATION=when_required` in the
  environment (#1431). Later versions set it themselves unless the environment already does.

### Verify a provider

An opt-in test module checks a bucket in one command. It writes under a unique `floe-s3compat-<id>/` prefix and
deletes it afterwards.

```bash
export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=...
FLOE_S3COMPAT_ENDPOINT=https://s3.fr-par.scw.cloud FLOE_S3COMPAT_BUCKET=my-bucket \
  FLOE_S3COMPAT_REGION=fr-par FLOE_S3COMPAT_PATH_STYLE=true \
  uv run pytest -m s3compat tests/integration/test_s3_compatible.py
```

`FLOE_S3COMPAT_REGION` defaults to `us-east-1`. `FLOE_S3COMPAT_PATH_STYLE` (`true` or `false`) applies to every check
but the addressing one; unset keeps the client default. Without the endpoint and bucket the tests are skipped.

It covers list, read, write, copy, delete, the download of a ~32 MiB Parquet file, the three conditional-write
checks (`If-None-Match: *` on an existing key, a stale `If-Match` put, a stale `If-Match` delete), a race of
concurrent conditional puts, both addressing styles, and a `floe run` with `incremental_mode: file` and one with
`archive` against the bucket. A failing check is a recorded result: `-k conditional` shows the conditional writes
alone, and `-k "path-style"` or `-k virtual-hosted` one addressing style. The stale `If-Match` delete is a raw
probe: Floe's state needs only conditional puts.

Iceberg FileIO and DuckDB merges reaching the endpoint are not automated, since they need a REST catalog backed
by the bucket. Check them by running an entity with an Iceberg `merge_scd1` sink against such a catalog (the `s3`
storage above with `endpoint` and `path_style_access`, see [Iceberg](https://openlakeforge.dev/floe/sinks/iceberg/)), and confirming the
table's data files land in the bucket.

With a local Polaris (the image CI uses, `.github/workflows/python-integration.yml`), give the container the
provider's `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `AWS_REGION` (Polaris writes table metadata itself),
and create the catalog with `storageConfigInfo` set to the provider's `endpoint` and `region`,
`"pathStyleAccess": true` and `"stsUnavailable": true`. Floe creates each table at its sink `path`, which is
outside the namespace's directory, so the catalog also needs the property
`polaris.config.allow.unstructured.table.location: "true"`; without it `create_table` fails with
`ForbiddenException: Invalid locations`.

---

<small>Synced from floe @ `v1.1.0` (`313b534`), [docs/storages/s3.md](https://github.com/OpenLakeForge/floe/blob/313b53441b3b088290403ed1adb2f3894833b6c5/docs/storages/s3.md).</small>
