⌘K ctrl+k
Search Shortcut cmd + k | ctrl + k

Getting Started with DuckDB on AWS

This guide is for readers who are new to using DuckDB with Amazon Web Services (AWS). It walks through reading public data from Amazon S3, authenticating with your AWS credentials, reading and writing your own files on S3, querying tables registered in the AWS Glue Data Catalog, and connecting to Amazon Athena and Amazon Redshift. Along the way, it explains which DuckDB extension is responsible for each step.

Which Extension Does What

DuckDB's AWS support is split across several extensions. You rarely have to install the core extensions by hand: they are autoloaded the first time you use a feature they provide.

Extension What it provides Maintainer Installation
httpfs Reading and writing s3:// URLs over the S3 API, and the config secret provider for static credentials DuckDB team Core extension, autoloaded
aws The credential_chain secret provider, which fetches credentials through the AWS SDK, and IAM authentication tokens for Amazon RDS DuckDB team Core extension, autoloaded
glue Attaching an AWS Glue Data Catalog as a DuckDB database DuckDB team Core extension, autoloaded
iceberg Reading Iceberg tables, including those in AWS Glue and Amazon S3 Tables DuckDB team Core extension, autoloaded
athena Connecting to Amazon Athena AWS AWS service repository
redshift Running queries on Amazon Redshift AWS AWS service repository

Reading Public Data from S3

Public buckets can be read without credentials. For example, the NOAA Global Historical Climatology Network Daily dataset on the Registry of Open Data on AWS is stored as Parquet files in a public bucket. To count the daily maximum temperature measurements of 2023, run:

SELECT
    count(*) AS num_measurements,
    count(DISTINCT ID) AS num_stations
FROM 's3://noaa-ghcn-pds/parquet/by_year/YEAR=2023/ELEMENT=TMAX/*.parquet';

The first s3:// URL autoloads the httpfs extension, which implements DuckDB's S3 support. The * glob matches all Parquet files in the directory, and as the directories follow the key=value naming scheme of Hive partitioning, DuckDB adds YEAR and ELEMENT as columns automatically. CSV and JSON files on S3 work the same way.

Authenticating

Private buckets require credentials. DuckDB manages credentials as secrets, which you create with the CREATE SECRET statement. An S3 secret uses one of two providers: credential_chain, which finds your existing AWS credentials, or config, where you pass a key directly. The S3 and AWS Authentication page helps you choose between them.

Using Your Existing AWS Configuration

If you already use the AWS CLI or an AWS SDK on your machine, the easiest option is the credential_chain provider. It is provided by the aws extension and fetches credentials through the AWS SDK, from the same sources as the AWS CLI, such as environment variables and the profiles in ~/.aws:

CREATE SECRET (
    TYPE s3,
    PROVIDER credential_chain
);

To use a named profile instead of the default one, select it with PROFILE:

CREATE SECRET (
    TYPE s3,
    PROVIDER credential_chain,
    CHAIN config,
    PROFILE 'my_profile'
);

If your organization signs in through AWS IAM Identity Center (SSO), sign in with the AWS CLI first. DuckDB then picks up the token that the CLI cached:

aws sso login --profile my-sso-profile
CREATE SECRET (
    TYPE s3,
    PROVIDER credential_chain,
    CHAIN 'sso',
    PROFILE 'my-sso-profile'
);

The credential_chain provider also supports assuming an IAM role, IAM Roles for Service Accounts (IRSA) on Amazon EKS, and automatic credential refresh. See the AWS extension page for all options.

Using an Access Key

If you have a static access key, pass it with the config provider, which is part of the httpfs extension. As config is the default provider, the PROVIDER clause can be omitted:

CREATE SECRET (
    TYPE s3,
    KEY_ID 'AKIAIOSFODNN7EXAMPLE',
    SECRET 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
    REGION 'us-east-1'
);

The config provider is not specific to AWS: with an ENDPOINT, it also works with other S3-compatible storage services. See the S3 API Support page for all secret parameters.

Setting the Region

Set REGION to the region of the bucket you are querying. If a config secret has no REGION, it defaults to us-east-1. A credential_chain secret without REGION looks for the region in the s3_region setting, in the AWS_REGION and AWS_DEFAULT_REGION environment variables, and in your profile, as described in Region Resolution.

Managing Secrets

Secrets are temporary by default and last until DuckDB exits. To keep a secret across sessions, create it with CREATE PERSISTENT SECRET. Note that persistent secrets are stored unencrypted on disk.

If different buckets need different credentials, give each secret a SCOPE, and DuckDB picks the secret with the longest matching prefix:

CREATE SECRET team_bucket (
    TYPE s3,
    PROVIDER credential_chain,
    CHAIN config,
    PROFILE 'team_profile',
    SCOPE 's3://team-bucket'
);

To check which secret DuckDB uses for a path, and to list all secrets (with sensitive values redacted), run:

FROM which_secret('s3://team-bucket/file.parquet', 's3');
FROM duckdb_secrets();

Reading and Writing Your Files on S3

With a secret in place, s3:// paths behave like local paths. You can read a single file:

SELECT *
FROM 's3://my-bucket/file.parquet';

Or read many files at once using globbing. The filename option adds a column that tells you which file each row came from:

SELECT *
FROM read_parquet('s3://my-bucket/folder/*.parquet', filename = true);

To write a table to S3, use COPY. DuckDB uploads the file using the S3 multipart upload API:

COPY orders TO 's3://my-bucket/orders.parquet';

To write a partitioned dataset, use the PARTITION_BY option:

COPY orders TO 's3://my-bucket/orders' (
    FORMAT parquet,
    PARTITION_BY (order_year)
);

For more details, see the S3 API Support page and the S3 Parquet Import, S3 Parquet Export, and S3 Express One guides.

Querying the AWS Glue Data Catalog

If your tables are registered in the AWS Glue Data Catalog, you can query them by name instead of by file path. The glue extension attaches a Glue catalog as a DuckDB database, with each Glue database appearing as a schema. It uses your S3 secret both for the Glue API and for the table files on S3, so the secret (or the ATTACH statement) has to specify a region:

CREATE SECRET (
    TYPE s3,
    PROVIDER credential_chain,
    REGION 'eu-central-1'
);
ATTACH ':' AS my_datalake (TYPE glue, READ_ONLY true);

The : path attaches the default catalog of your account; see Catalog Identifiers for other catalogs. The READ_ONLY option is a good safeguard while you explore. Leave it out when you want to create tables or insert data. Then, list and query the tables:

SHOW ALL TABLES;

SELECT *
FROM my_datalake.glue_database.table_name;

The glue extension reads and writes Glue's native Hive tables stored as Parquet, CSV, JSON, or Avro files. Tables of other formats are listed but cannot be read through it. To read Iceberg tables registered in Glue, attach the same catalog with the iceberg extension:

ATTACH 'account_id' AS glue_catalog (
    TYPE iceberg,
    ENDPOINT_TYPE 'glue'
);

The iceberg extension can also attach Amazon S3 Tables catalogs. For writing to Glue, partition management, views, and limitations, see the glue extension page.

Connecting to Athena and Redshift

Warning The Athena and Redshift extensions are not DuckDB core extensions. They are developed and maintained by AWS.

AWS publishes these extensions in its own AWS service repository rather than in DuckDB's built-in repositories. Before you can install them, register the repository. This requires DuckDB v2.0.1 or later and only has to be done once on each machine:

CREATE EXTENSION REPOSITORY aws.amazon.com;

Then, install and load the extension you need. For example, the Redshift extension runs queries on Amazon Redshift and returns the results as DuckDB tables, which you can join with local data or with files on S3:

INSTALL AND LOAD redshift FROM aws.amazon.com;

ATTACH 'redshift://workgroup.account_id.region.redshift-serverless.amazonaws.com/database' AS rs (
    TYPE redshift,
    SECRET aws_secret
);
SELECT * FROM redshift_query('rs', 'SELECT current_user');

Here, aws_secret is the name of a secret created with the credential_chain provider, as shown in Authenticating. The query passed to redshift_query runs on Redshift, using Redshift's SQL dialect.

Extensions from the AWS service repository are not autoloaded. In later sessions, load them explicitly:

LOAD redshift FROM aws.amazon.com;

The Athena extension connects DuckDB to Amazon Athena and is installed from the same repository. For details on both extensions, see the AWS Service Extensions page.

See Also

© 2026 DuckDB Foundation, Amsterdam NL
DuckDB Home Code of Conduct Trademark Use Blog