Skip to main content

S3 Destination

Upload sync batches to an Amazon S3 bucket as CSV / JSON / JSONL / Parquet files. Optional gzip compression for the text formats; native column compression for Parquet.

YAML Example — CSV with gzip​

destination:
type: s3
bucket: my-data-exports
prefix: drt/users/
format: csv
compression: gzip
region: us-east-1

Default key format: <prefix><UTC ISO8601 basic>.<ext> → drt/users/20260605T123000Z.csv.gz.

YAML Example — Parquet​

destination:
type: s3
bucket: my-data-lake
prefix: events/
format: parquet
parquet_compression: snappy
region: eu-west-1

YAML Example — JSONL to MinIO / R2 / S3-compatible​

destination:
type: s3
bucket: events
prefix: drt/
format: jsonl
endpoint_url: http://minio.internal:9000
aws_access_key_id_env: MINIO_ACCESS_KEY
aws_secret_access_key_env: MINIO_SECRET_KEY

Configuration​

FieldTypeDefaultDescription
type"s3"—Required
bucketstring—S3 bucket name
prefixstring""Key prefix; for per-sync routing, set a unique prefix per sync
formatcsv | json | jsonl | parquetcsvOutput format
compressionnone | gzipnonegzip compresses csv / json / jsonl. Ignored for parquet (see parquet_compression)
parquet_compressionsnappy | gzip | zstd | nonesnappyParquet column compression (Parquet only)
regionstring | nullnullAWS region; falls back to boto3 default
aws_profilestring | nullnullNamed profile in ~/.aws/credentials
aws_access_key_id_envstring | nullnullEnv var holding AWS_ACCESS_KEY_ID value
aws_secret_access_key_envstring | nullnullEnv var holding AWS_SECRET_ACCESS_KEY value
aws_session_token_envstring | nullnullEnv var holding AWS_SESSION_TOKEN value
endpoint_urlstring | nullnullFor MinIO / LocalStack / R2 / Spaces
key_templatestring | nullnullOverride the file name; supports {timestamp} placeholder

Authentication​

By default the destination uses boto3's standard credential chain:

  1. Environment variables (AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN)
  2. ~/.aws/credentials (default profile)
  3. EC2 instance profile / ECS task role / IAM role

This works without any YAML changes in the typical EC2 / ECS / EKS deployment.

Named profile (when running locally with multiple AWS accounts):

aws_profile: prod-readonly

Explicit env vars (when secrets are managed outside drt's standard credential mechanism, e.g. when injecting per-sync credentials through a secret manager):

aws_access_key_id_env: APP_AWS_KEY_ID
aws_secret_access_key_env: APP_AWS_SECRET

File naming​

Every sync writes one file. The default key is:

<prefix><UTC ISO8601 basic>.<ext>

— for example drt/users/20260605T123000Z.csv. Timestamping the key (rather than overwriting a fixed name) matches the Census / Hightouch convention and lets downstream consumers reliably detect "new files since last check".

Custom naming via key_template​

For per-sync routing, the recommended pattern is to use a sync-specific prefix:

destination:
type: s3
bucket: data-lake
prefix: drt/active_users/ # per-sync prefix

For more control, set key_template. The only supported placeholder is {timestamp}. If the template includes its own extension, it is used as-is; otherwise the format-derived extension is appended.

# Produces: drt/users/snapshot-20260605T123000Z.csv
key_template: "snapshot-{timestamp}"
# Produces: drt/users/latest.csv (no timestamp, no auto-extension)
key_template: "latest.csv"

Format details​

FormatEncodingNotes
csvUTF-8Header row (column names) + csv.DictWriter, RFC 4180. Empty rows raise.
jsonUTF-8JSON array of objects ([{...}, {...}])
jsonlUTF-8One JSON object per line — the de-facto data-lake standard
parquetbinaryVia pandas + pyarrow. Requires the separate [parquet] extra.

compression: gzip is applied AFTER serialisation for the text formats and sets the ContentEncoding: gzip header on the S3 object. Use this for downstream consumers that decompress transparently (Athena, Glue, Snowpipe, etc.).

Sync modes​

S3 destinations write one file per sync run. Because the default key is timestamped, every run produces a fresh object — there is no "replace existing data" semantic for an S3 destination. sync.mode values (full, incremental, upsert, replace, mirror) don't change S3 behaviour: every batch becomes a row inside the file, and the file is uploaded once when the batch completes.

If you need "latest snapshot" semantics, point key_template at a fixed name like latest.csv — downstream consumers will see an overwrite each run. Note that this loses re-run replay since prior exports are gone.

Notes​

  • Requires pip install drt-core[s3] (depends on boto3>=1.34).
  • For format: parquet, also requires pip install drt-core[parquet].
  • Empty batches short-circuit before any boto3 import or AWS call — the same "no driver was imported" contract used by the SQL destinations. A run with zero source rows produces zero S3 objects.
  • Errors during serialisation are recorded in result.errors and fail the sync. Errors during upload (AWS-side) are recorded as result.failed = len(records) so the sync's other batches keep going.
  • Bucket policies / IAM roles must allow s3:PutObject on the prefix.

References​