Skip to content

Commit

Permalink
PDS: Allow configuring non-AWS S3 blob storage. (#1729)
Browse files Browse the repository at this point in the history
* PDS: Allow configuring non-AWS S3 blob storage.

See #1583

* tidy

---------

Co-authored-by: devin ivy <[email protected]>
  • Loading branch information
YOCKOW and devinivy authored Oct 30, 2023
1 parent fcb19c9 commit b28fdb2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/pds/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ export const envToCfg = (env: ServerEnvironment): ServerConfig => {
}
if (env.blobstoreS3Bucket) {
blobstoreCfg = { provider: 's3', bucket: env.blobstoreS3Bucket }
if (env.blobstoreS3Region) {
blobstoreCfg.region = env.blobstoreS3Region
}
if (env.blobstoreS3Endpoint) {
blobstoreCfg.endpoint = env.blobstoreS3Endpoint
}
if (env.blobstoreS3ForcePathStyle !== undefined) {
blobstoreCfg.forcePathStyle = env.blobstoreS3ForcePathStyle
}
} else if (env.blobstoreDiskLocation) {
blobstoreCfg = {
provider: 'disk',
Expand Down Expand Up @@ -238,6 +247,9 @@ export type PostgresConfig = {
export type S3BlobstoreConfig = {
provider: 's3'
bucket: string
region?: string
endpoint?: string
forcePathStyle?: boolean
}

export type DiskBlobstoreConfig = {
Expand Down
8 changes: 8 additions & 0 deletions packages/pds/src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const readEnv = (): ServerEnvironment => {
// blobstore: one required
// s3
blobstoreS3Bucket: envStr('PDS_BLOBSTORE_S3_BUCKET'),
blobstoreS3Region: envStr('PDS_BLOBSTORE_S3_REGION'),
blobstoreS3Endpoint: envStr('PDS_BLOBSTORE_S3_ENDPOINT'),
blobstoreS3ForcePathStyle: envBool('PDS_BLOBSTORE_S3_FORCE_PATH_STYLE'),
// disk
blobstoreDiskLocation: envStr('PDS_BLOBSTORE_DISK_LOCATION'),
blobstoreDiskTmpLocation: envStr('PDS_BLOBSTORE_DISK_TMP_LOCATION'),
Expand Down Expand Up @@ -118,6 +121,11 @@ export type ServerEnvironment = {
blobstoreDiskLocation?: string
blobstoreDiskTmpLocation?: string

// -- optional s3 parameters
blobstoreS3Region?: string
blobstoreS3Endpoint?: string
blobstoreS3ForcePathStyle?: boolean

// identity
didPlcUrl?: string
didCacheStaleTTL?: number
Expand Down
7 changes: 6 additions & 1 deletion packages/pds/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ export class AppContext {
})
const blobstore =
cfg.blobstore.provider === 's3'
? new S3BlobStore({ bucket: cfg.blobstore.bucket })
? new S3BlobStore({
bucket: cfg.blobstore.bucket,
region: cfg.blobstore.region,
endpoint: cfg.blobstore.endpoint,
forcePathStyle: cfg.blobstore.forcePathStyle,
})
: await DiskBlobStore.create(
cfg.blobstore.location,
cfg.blobstore.tempLocation,
Expand Down

0 comments on commit b28fdb2

Please sign in to comment.