Downloads icon
Concat icon
Upload icon
Queries icon
aws icon

Register S3 JSON files as governed datasets and curate them with DuckDB

Ingest JSON from Amazon S3, merge and curate it with DuckDB, and register raw, staging, and curated dataset assets as governed Kestra assets with lineage.

Categories
Data

This blueprint turns a pile of raw JSON files in Amazon S3 into a curated, governed dataset with end to end lineage. It downloads matching JSON objects from an S3 bucket, merges them into one unified file, stages that file back to S3, curates it with DuckDB, and registers each transformation as a tracked dataset asset. It solves a common data engineering problem: ingesting semi-structured JSON from object storage while keeping a clear, auditable trail of how raw inputs became a clean, queryable dataset.

How it works

  1. download_json_from_s3 (io.kestra.plugin.aws.s3.Downloads) pulls every object in the bucket matching the regexp filter from the chosen region and registers them as a raw dataset asset (raw_json_files).
  2. concat_dynamic_one (io.kestra.plugin.core.storage.Concat) merges the downloaded files into a single unified-data.json and registers it as a staging dataset asset.
  3. upload_unified_json_to_s3 (io.kestra.plugin.aws.s3.Upload) writes the unified file to processed/{{ flow.id }}/unified-data.json and registers a staging_s3 asset.
  4. duckdb_process_and_query (io.kestra.plugin.jdbc.duckdb.Queries) loads the unified JSON into DuckDB with read_json, builds a unified_dataset table, and persists a curated dataset asset (with outputDbFile enabled).
  5. ship_assets (io.kestra.plugin.ee.assets.AssetShipper) exports the curated dataset as JSON for downstream consumers.

What you get

  • A single unified JSON file built from many scattered S3 objects.
  • A curated DuckDB table queried and stored for reuse.
  • Four governed dataset assets spanning raw, staging, S3 staging, and curated layers.
  • Automatic lineage linking each asset to the task that produced it.

Who it's for

  • Data engineers consolidating semi-structured JSON landing in object storage.
  • Analytics teams that need a governed, queryable view of raw S3 data.
  • Platform teams enforcing dataset lineage and cataloging across pipelines.

Why orchestrate this with Kestra

S3 and DuckDB have no shared scheduler or cross-tool lineage. Kestra ties the download, merge, upload, and curation steps into one declarative YAML flow, with event triggers, retries, and asset lineage that the individual tools cannot provide on their own. Every step registers a typed io.kestra.plugin.ee.assets.Dataset, so the catalog shows exactly how raw inputs flowed into the curated table, something neither S3 lifecycle rules nor DuckDB can track.

Prerequisites

An S3 bucket containing JSON files (the defaults expect names like lead-001.json) and a Kestra Enterprise Edition instance for asset governance.

Secrets

  • AWS_ACCESS_KEY_ID: IAM access key with read and write access to the source bucket.
  • AWS_SECRET_KEY_ID: IAM secret key paired with the access key.

Quick start

  1. Set the bucket, regexp, and region inputs to target your JSON files.
  2. Configure the AWS_ACCESS_KEY_ID and AWS_SECRET_KEY_ID secrets in Kestra.
  3. Run the flow to download, merge, stage to S3, curate with DuckDB, and ship assets.
  4. Open the asset catalog to inspect the raw, staging, S3 staging, and curated datasets with their metadata and lineage.

How to extend

  • Add a Schedule or S3 event trigger to run the flow automatically on new files.
  • Replace the DuckDB SQL with aggregations, joins, or deduplication to enrich the curated table.
  • Route the shipped asset to a warehouse such as Snowflake or BigQuery for analytics.
  • Add validation tasks and errors handling to quarantine malformed JSON.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.