Register a generic S3 (S3-compatible) secret on a connection

Source: R/secret_fns.R

Creates (or replaces) a DuckDB/MotherDuck secret of ⁠TYPE S3⁠ for AWS S3 or any S3-compatible object store (Cloudflare R2, MinIO, Backblaze B2, etc.). For Cloudflare R2 prefer the create_r2_secret() shortcut.

Usage

create_s3_secret(
  .con,
  key_id,
  secret,
  endpoint = NULL,
  region = NULL,
  url_style = NULL,
  use_ssl = NULL,
  name = "s3",
  persistent = FALSE
)

Arguments

.con

A valid DBI connection (DuckDB / MotherDuck).

key_id

R2 S3 access key id.

secret

R2 S3 secret access key.

endpoint

Optional host of the S3-compatible endpoint, e.g. “<account>.r2.cloudflarestorage.com”. Omit for AWS S3.

region

Optional region, e.g. “us-east-1”. R2 ignores this.

url_style

Optional “path” or “vhost”. S3-compatible stores usually need “path”.

use_ssl

Optional logical; use HTTPS. Defaults to NULL (engine default).

name

Secret name. Defaults to “s3”.

persistent

Logical; persist the secret to the local store. Defaults to FALSE (session-scoped).

Value

Invisibly, the secret name.

Details

Requires the httpfs extension. Optional fields (endpoint, region, url_style, use_ssl) are only emitted when supplied, so the same helper covers AWS (region only) and self-hosted stores (custom endpoint + url_style = “path”).

See Also

create_r2_secret(), load_extensions()

Other db-manage: alter_table_schema(), copy_tables_to_new_location(), create_database(), create_if_not_exists_share(), create_or_replace_share(), create_r2_secret(), create_schema(), create_table(), delete_and_create_schema(), delete_database(), delete_schema(), delete_table(), describe_share(), drop_share(), list_owned_shares(), list_shared_with_me_shares(), upload_database_to_md()

Examples

con <- connect_to_motherduck()
load_extensions(con, "httpfs")
create_s3_secret(con, key_id = "AKIA...", secret = "...", region = "us-east-1")