diff --git a/api-backend/.env.example b/api-backend/.env.example index 0012702..95ac22c 100644 --- a/api-backend/.env.example +++ b/api-backend/.env.example @@ -19,10 +19,15 @@ REDIS_PORT= # AWS AWS_ACCESS_KEY= AWS_SECRET_KEY= +AWS_REGION= -## S3 -AWS_BUCKET_REGION= -AWS_MEETING_BOT_BUCKET_NAME= + +## S3 (aws S3 or Cloudflare R2) +S3_ACCESS_KEY= +S3_SECRET_KEY= +S3_ENDPOINT_URL= #use this only with R2 +S3_BUCKET_NAME= +S3_REGION= ## ECS AWS_ECS_CLUSTER_NAME= diff --git a/api-backend/src/aws/aws.service.ts b/api-backend/src/aws/aws.service.ts index 1dae6c3..739149a 100644 --- a/api-backend/src/aws/aws.service.ts +++ b/api-backend/src/aws/aws.service.ts @@ -12,11 +12,14 @@ export class AwsService { constructor(readonly configService: ConfigService) { this.s3 = new S3({ + ...(this.configService.get('s3.endpoint') && { + endpoint: this.configService.get('s3.endpoint'), + }), credentials: { - accessKeyId: this.configService.get('aws.accessKey'), - secretAccessKey: this.configService.get('aws.secretKey'), + accessKeyId: this.configService.get('s3.accessKey'), + secretAccessKey: this.configService.get('s3.secretKey'), }, - region: this.configService.get('aws.bucketRegion'), + region: this.configService.get('s3.region'), }); } @@ -30,7 +33,7 @@ export class AwsService { try { const input: PutObjectCommandInput = { - Bucket: this.configService.get('aws.meetingBotBucketName'), + Bucket: this.configService.get('s3.bucketName'), Key: objectName, ContentType: contentType, Metadata: metadata, diff --git a/api-backend/src/aws/ecs.service.ts b/api-backend/src/aws/ecs.service.ts index 444ab4b..7575c3b 100644 --- a/api-backend/src/aws/ecs.service.ts +++ b/api-backend/src/aws/ecs.service.ts @@ -62,7 +62,7 @@ export class ECSClientService { accessKeyId: this.configService.get('aws.accessKey'), secretAccessKey: this.configService.get('aws.secretKey'), }, - region: this.configService.get('aws.bucketRegion'), + region: this.configService.get('aws.region'), }); this.clusterName = this.configService.get('aws.ecsClusterName'); } diff --git a/api-backend/src/config/configuration.ts b/api-backend/src/config/configuration.ts index 1f30430..9481e9b 100644 --- a/api-backend/src/config/configuration.ts +++ b/api-backend/src/config/configuration.ts @@ -17,11 +17,10 @@ export default () => ({ aws: { accessKey: process.env.AWS_ACCESS_KEY, secretKey: process.env.AWS_SECRET_KEY, - bucketRegion: process.env.AWS_BUCKET_REGION, + region: process.env.AWS_REGION, ecsClusterName: process.env.AWS_ECS_CLUSTER_NAME, securityGroup: process.env.AWS_SECURITY_GROUP, vpsSubnet: process.env.AWS_VPS_SUBNET, - meetingBotBucketName: process.env.AWS_MEETING_BOT_BUCKET_NAME, ecsTaskDefinitionGoogle: process.env.ECS_TASK_DEFINITION_GOOGLE, ecsContainerNameGoogle: process.env.ECS_CONTAINER_NAME_GOOGLE, ecsTaskDefinitionTeams: process.env.ECS_TASK_DEFINITION_TEAMS, @@ -29,6 +28,13 @@ export default () => ({ ecsTaskDefinitionZoom: process.env.ECS_TASK_DEFINITION_ZOOM, ecsContainerNameZoom: process.env.ECS_CONTAINER_NAME_ZOOM, }, + s3: { + endpoint: process.env.S3_ENDPOINT_URL, + bucketName: process.env.S3_BUCKET_NAME, + accessKey: process.env.S3_ACCESS_KEY, + secretKey: process.env.S3_SECRET_KEY, + region: process.env.S3_REGION, + }, bot: { meetingBotRetryCount: parseInt(process.env.MEETING_BOT_RETRY_COUNT, 10) || 2,