diff --git a/packages/twenty-server/src/engine/integrations/environment/environment-variables.ts b/packages/twenty-server/src/engine/integrations/environment/environment-variables.ts index 7bff532c4..423dee3b3 100644 --- a/packages/twenty-server/src/engine/integrations/environment/environment-variables.ts +++ b/packages/twenty-server/src/engine/integrations/environment/environment-variables.ts @@ -220,6 +220,16 @@ export class EnvironmentVariables { @IsOptional() STORAGE_S3_ENDPOINT: string; + @ValidateIf((env) => env.STORAGE_TYPE === StorageDriverType.S3) + @IsString() + @IsOptional() + STORAGE_S3_ACCESS_KEY_ID: string; + + @ValidateIf((env) => env.STORAGE_TYPE === StorageDriverType.S3) + @IsString() + @IsOptional() + STORAGE_S3_SECRET_ACCESS_KEY: string; + @IsString() @ValidateIf((env) => env.STORAGE_TYPE === StorageDriverType.Local) STORAGE_LOCAL_PATH = '.local-storage'; diff --git a/packages/twenty-server/src/engine/integrations/file-storage/file-storage.module-factory.ts b/packages/twenty-server/src/engine/integrations/file-storage/file-storage.module-factory.ts index f846dc96d..b1ab03642 100644 --- a/packages/twenty-server/src/engine/integrations/file-storage/file-storage.module-factory.ts +++ b/packages/twenty-server/src/engine/integrations/file-storage/file-storage.module-factory.ts @@ -32,15 +32,24 @@ export const fileStorageModuleFactory = async ( const bucketName = environmentService.get('STORAGE_S3_NAME'); const endpoint = environmentService.get('STORAGE_S3_ENDPOINT'); const region = environmentService.get('STORAGE_S3_REGION'); + const accessKeyId = environmentService.get('STORAGE_S3_ACCESS_KEY_ID'); + const secretAccessKey = environmentService.get( + 'STORAGE_S3_SECRET_ACCESS_KEY', + ); return { type: StorageDriverType.S3, options: { bucketName: bucketName ?? '', endpoint: endpoint, - credentials: fromNodeProviderChain({ - clientConfig: { region }, - }), + credentials: accessKeyId + ? { + accessKeyId, + secretAccessKey, + } + : fromNodeProviderChain({ + clientConfig: { region }, + }), forcePathStyle: true, region: region ?? '', }, diff --git a/packages/twenty-website/src/content/developers/self-hosting/self-hosting-var.mdx b/packages/twenty-website/src/content/developers/self-hosting/self-hosting-var.mdx index 88ae2e511..7d50e1a08 100644 --- a/packages/twenty-website/src/content/developers/self-hosting/self-hosting-var.mdx +++ b/packages/twenty-website/src/content/developers/self-hosting/self-hosting-var.mdx @@ -142,6 +142,8 @@ yarn command:prod cron:calendar:google-calendar-sync ['STORAGE_S3_REGION', '', 'Storage Region'], ['STORAGE_S3_NAME', '', 'Bucket Name'], ['STORAGE_S3_ENDPOINT', '', 'Use if a different Endpoint is needed (for example Google)'], + ['STORAGE_S3_ACCESS_KEY_ID', '', 'Optional depending on the authentication method'], + ['STORAGE_S3_SECRET_ACCESS_KEY', '', 'Optional depending on the authentication method'], ['STORAGE_LOCAL_PATH', '.local-storage', 'data path (local storage)'], ]}>