Skip to content

Commit

Permalink
Add S3 config option for region and path-style
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryoverload committed Oct 16, 2024
1 parent 875e75f commit eb31c88
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || ''
Expand Down Expand Up @@ -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';
Expand Down
2 changes: 2 additions & 0 deletions src/types/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface Config {
endpoint: string;
key: string;
secret: string;
region: string;
forcePathStyle: boolean;
};
hcaptcha: {
secret: string;
Expand Down
2 changes: 2 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit eb31c88

Please sign in to comment.