# Amazon S3

Send2Bucket assumes an IAM role in your AWS account to write to S3. The role’s trust policy must require the destination’s external ID. This prevents another Send2Bucket customer from using your role.

## What you provide

| Setting | Example |
|---|---|
| `bucket` | `analytics-raw` |
| `region` | `us-east-1` |
| `prefix` | `raw` |
| `role_arn` | `arn:aws:iam::123456789012:role/s2bucket-writer` |

You also need two values from Send2Bucket. The dashboard shows both, with the trust policy below filled in:

- Send2Bucket's AWS principal, shown in the dashboard on the destination;
- the external ID, generated for each destination.

## 1. Create the role

Create an IAM role with this trust policy:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {"AWS": "<aws_principal>"},
      "Action": "sts:AssumeRole",
      "Condition": {"StringEquals": {"sts:ExternalId": "<external_id>"}}
    }
  ]
}
```

## 2. Allow writes under the prefix

Attach this permissions policy to the role. `s3:PutObject` writes delivery objects. `s3:GetObject` covers reading back the setup test object and the `HEAD` request Send2Bucket makes to check an object after a lost upload response.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:PutObject", "s3:GetObject"],
      "Resource": "arn:aws:s3:::analytics-raw/raw/s2b/*"
    }
  ]
}
```

If the bucket uses SSE-KMS with a customer managed key, also allow `kms:GenerateDataKey` and `kms:Decrypt` on that key.

## 3. Add the destination

In the dashboard, enter the four settings and select Verify. Send2Bucket assumes the role, writes a test object under `raw/s2b/` and reads it back. The destination becomes `active` once that check, or the first delivery, passes.

For OpenTelemetry from SDKs or a Collector, see [Send OpenTelemetry to Amazon S3](../guides/opentelemetry-to-s3.md).

## Objects

Objects land at `raw/s2b/stream=<stream_id>/date=YYYY-MM-DD/hour=HH/<delivery_batch_id>.ndjson.gz`. See [Delivery format](../delivery-format.md). Lifecycle rules, replication and retention on the bucket are yours to set.

## Query your data

- [DuckDB](../querying/duckdb.md#amazon-s3): reads the objects in place.
- [Trino](../querying/trino.md): external table over the bucket; Athena uses the same table definition.
- [BigQuery](../querying/bigquery.md#other-destinations): through BigQuery Omni.
- [PostgreSQL](../querying/postgres.md): load into `jsonb`.
- [MySQL](../querying/mysql.md): load into `JSON`.
- [Python](../querying/python.md): Polars, PyIceberg or the duckdb package.
- [R](../querying/r.md): the duckdb package.
- [Amazon Athena](../querying/athena.md)
- [ClickHouse](../querying/clickhouse.md)
- [Amazon Redshift](../querying/redshift.md)
- [Snowflake](../querying/snowflake.md)
- [Microsoft Fabric](../querying/fabric.md)
- [Databricks](../querying/databricks.md)
- [Apache Spark](../querying/spark.md)
- [StarRocks](../querying/starrocks.md)
- [Dremio](../querying/dremio.md)

To explore in a notebook or BI tool, see [Integrations](../integrations/index.md). The [querying overview](../querying/index.md) compares engines.
