Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions graphile/graphile-settings/src/bucket-provisioner-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,22 @@ export function getBucketProvisionerConnection(): StorageConnectionConfig {

const { cdn } = getEnvOptions();

// cdn is guaranteed populated — pgpmDefaults provides all CDN fields
const { provider, awsRegion, awsAccessKey, awsSecretKey, endpoint } = cdn!;
if (!cdn) {
throw new Error(
'[bucket-provisioner-resolver] CDN config not found. ' +
'Ensure CDN environment variables (AWS_ACCESS_KEY, AWS_SECRET_KEY, etc.) ' +
'are set or that pgpmDefaults provides CDN fields.',
);
}

const { provider, awsRegion, awsAccessKey, awsSecretKey, endpoint } = cdn;

if (!awsAccessKey || !awsSecretKey) {
throw new Error(
'[bucket-provisioner-resolver] Missing S3 credentials. ' +
'Set AWS_ACCESS_KEY and AWS_SECRET_KEY environment variables.',
);
}

log.info(
`[bucket-provisioner-resolver] Initializing: provider=${provider} endpoint=${endpoint}`,
Expand All @@ -39,8 +53,8 @@ export function getBucketProvisionerConnection(): StorageConnectionConfig {
connectionConfig = {
provider: (provider as StorageConnectionConfig['provider']) || 'minio',
region: awsRegion || 'us-east-1',
accessKeyId: awsAccessKey!,
secretAccessKey: awsSecretKey!,
accessKeyId: awsAccessKey,
secretAccessKey: awsSecretKey,
...(endpoint ? { endpoint, forcePathStyle: true } : {}),
};

Expand Down
29 changes: 25 additions & 4 deletions graphile/graphile-settings/src/presigned-url-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,43 @@ export function getPresignedUrlS3Config(): S3Config {

const { cdn } = getEnvOptions();

// cdn is guaranteed populated — pgpmDefaults provides all CDN fields
const { bucketName, awsRegion, awsAccessKey, awsSecretKey, endpoint, publicUrlPrefix } = cdn!;
if (!cdn) {
throw new Error(
'[presigned-url-resolver] CDN config not found. ' +
'Ensure CDN environment variables (AWS_ACCESS_KEY, AWS_SECRET_KEY, etc.) ' +
'are set or that pgpmDefaults provides CDN fields.',
);
}

const { bucketName, awsRegion, awsAccessKey, awsSecretKey, endpoint, publicUrlPrefix } = cdn;

if (!awsAccessKey || !awsSecretKey) {
throw new Error(
'[presigned-url-resolver] Missing S3 credentials. ' +
'Set AWS_ACCESS_KEY and AWS_SECRET_KEY environment variables.',
);
}

if (!bucketName) {
throw new Error(
'[presigned-url-resolver] Missing CDN bucket name. ' +
'Set CDN_BUCKET_NAME environment variable.',
);
}

log.info(
`[presigned-url-resolver] Initializing: bucket=${bucketName} endpoint=${endpoint}`,
);

const client = new S3Client({
region: awsRegion,
credentials: { accessKeyId: awsAccessKey!, secretAccessKey: awsSecretKey! },
credentials: { accessKeyId: awsAccessKey, secretAccessKey: awsSecretKey },
...(endpoint ? { endpoint, forcePathStyle: true } : {}),
});

s3Config = {
client,
bucket: bucketName!,
bucket: bucketName,
region: awsRegion,
publicUrlPrefix,
...(endpoint ? { endpoint, forcePathStyle: true } : {}),
Expand Down
Loading