Add S3 config option for region and path-style

This commit is contained in:
William Oldham 2024-10-16 13:34:42 +01:00 committed by William Oldham
parent 875e75f08f
commit eb31c88f83
3 changed files with 12 additions and 1 deletions

View File

@ -56,7 +56,9 @@ export const config: Config = {
s3: {
endpoint: process.env.PN_ACT_CONFIG_S3_ENDPOINT || '',
key: process.env.PN_ACT_CONFIG_S3_ACCESS_KEY || '',
secret: process.env.PN_ACT_CONFIG_S3_ACCESS_SECRET || ''
secret: process.env.PN_ACT_CONFIG_S3_ACCESS_SECRET || '',
region: process.env.PN_ACT_CONFIG_S3_REGION || '',
forcePathStyle: process.env.PN_ACT_CONFIG_S3_FORCE_PATH_STYLE === 'true'
},
hcaptcha: {
secret: process.env.PN_ACT_CONFIG_HCAPTCHA_SECRET || ''
@ -195,6 +197,11 @@ if (!config.s3.secret) {
disabledFeatures.s3 = true;
}
if (!config.s3.region) {
LOG_WARN('Failed to find S3 region config. Disabling feature. To enable feature set the PN_ACT_CONFIG_S3_REGION environment variable');
disabledFeatures.s3 = true;
}
if (!config.server_environment) {
LOG_WARN('Failed to find server environment. To change the environment, set the PN_ACT_CONFIG_SERVER_ENVIRONMENT environment variable. Defaulting to prod');
config.server_environment = 'prod';

View File

@ -30,6 +30,8 @@ export interface Config {
endpoint: string;
key: string;
secret: string;
region: string;
forcePathStyle: boolean;
};
hcaptcha: {
secret: string;

View File

@ -20,6 +20,8 @@ let s3: S3;
if (!disabledFeatures.s3) {
s3 = new S3({
endpoint: config.s3.endpoint,
forcePathStyle: config.s3.forcePathStyle,
region: config.s3.region,
credentials: {
accessKeyId: config.s3.key,