---
title: Using DuckDB with Fastly Object Storage
summary: null
url: >-
  https://www.fastly.com/documentation/guides/platform/object-storage/object-storage-duckdb
---

Fastly [Object Storage](https://docs.fastly.com/products/object-storage) works with the S3-compatible API to store and access large files from Fastly. This same API can be used with [DuckDB](https://duckdb.org), the fast, portable open-source, in-process analytical database.

## Prerequisites

To remotely load files from Fastly Object Storage into DuckDBextension, you must install the [`httpfs` DuckDBextension](https://duckdb.org/docs/stable/core_extensions/httpfs/overview) by running the [`INSTALL` SQL command](https://duckdb.org/docs/stable/extensions/overview.html#explicit-install-and-load). This only needs to be run once. DuckDB may also try to [auto-install](https://duckdb.org/docs/stable/extensions/overview.html#autoloading-extensions) the extension.

You will also need to create an [Object Storage access key](https://www.fastly.com/documentation/guides/platform/object-storage/working-with-object-storage#creating-an-object-storage-access-key) used to authenticate against the S3-compatible API.

## Using DuckDB with Fastly Object Storage

To use DuckDB with Fastly Object Storage, first create an [`S3` secret](https://duckdb.org/docs/configuration/secrets_manager.html) in DuckDB, setting the `CREATE SECRET` parameters as follows:

- `KEY_ID` and `SECRET`: enter the appropriate values generated from the [Object Storage access key](https://www.fastly.com/documentation/guides/platform/object-storage/working-with-object-storage#creating-an-object-storage-access-key) you created.
- `URL_STYLE`: enter `path`.
- `REGION`: enter the [Fastly data storage region](https://www.fastly.com/documentation/guides/platform/object-storage/working-with-object-storage#working-with-the-s3-compatible-api) you want to use (e.g. `us-west-1`).
- `ENDPOINT`: enter `<region>.object.fastlystorage.app` where `<region>` matches the region value above.

**Example:**

```sql
CREATE SECRET my_secret (
    TYPE S3,
    KEY_ID 'AKIAIOSFODNN7EXAMPLE',
    SECRET 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
	URL_STYLE 'path',
	REGION 'us-west-1',
    ENDPOINT 'us-west-1.object.fastlystorage.app' -- see note below
);
```

After setting up the Fastly Object Storage credentials, you can query the data using DuckDB's built-in methods, such as [`read_csv`](https://duckdb.org/docs/data/csv/overview) or [`read_parquet`](https://duckdb.org/docs/data/parquet/overview):

```sql
SELECT * FROM 's3://⟨fastly_bucket_name⟩/(file).csv';
SELECT * FROM read_parquet('s3://⟨fastly_bucket_name⟩/⟨file⟩.parquet');
```
