Skip to main content

Cloudflare R2

Configure Cloudflare R2 credentials

You can safely store your Cloudflare R2 credentials in MotherDuck for convenience by creating a SECRET object using the CREATE SECRET command.

note

See Cloudflare docs to create a Cloudflare access token.

Create a SECRET object

CREATE SECRET IN MOTHERDUCK (
TYPE R2,
KEY_ID 'your_key_id',
SECRET 'your_secret_key',
ACCOUNT_ID 'your_account_id'
);
note

The account_id can be found when generating the API token on the endpoint URL https://<ACCOUNT_ID>.r2.cloudflarestorage.com

-- test the R2 credentials
SELECT count(*) FROM 'r2://[bucket]/[file]'

Delete a SECRET object

You can use the same method above, using the DROP SECRET command.

DROP SECRET <secret_name>;

R2 credentials as temporary secrets

MotherDuck supports DuckDB syntax for providing Azure credentials.

CREATE SECRET (
TYPE R2,
KEY_ID 'your_key_id',
SECRET 'your_secret_key',
ACCOUNT_ID 'your_account_id'

);
note

Local/In-memory secrets are not persisted across sessions.