Skip to content

Commit

Permalink
fix: s3 경로 이상문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
kimsudang committed Jan 14, 2025
1 parent 5a8b278 commit e4cb13c
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/config/s3.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,12 @@ export class S3ConfigService {
private readonly region: string;

constructor(private readonly configService: ConfigService) {
// 우선순위 1: .env에서 직접 가져오기
this.bucketName = this.configService.get<string>('AWS_S3_BUCKET_NAME');
this.region = 'ap-northeast-2';

if (!this.bucketName || this.bucketName.trim() === '') {
throw new Error('[S3ConfigService] S3 Bucket Name이 .env에 설정되지 않았습니다.');
}

// region 값이 혹시 'function' 같은 문자열을 포함하는지 마지막으로 방어
if (this.region.includes('function') || this.region.includes('=>')) {
throw new Error(
`[S3ConfigService] region 값이 이상합니다: ${this.region}. \n.env나 환경 변수를 다시 확인하세요.`,
);
}

// AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY도 .env에서 가져오되
// 값을 못 찾으면 Error나 원하는 처리
const accessKeyId = this.configService.get<string>('AWS_ACCESS_KEY_ID');
Expand All @@ -35,7 +26,7 @@ export class S3ConfigService {

/// S3Client 생성
this.s3Client = new S3Client({
region: this.region, // 직접 하드코딩
region: 'ap-northeast-2', // 직접 하드코딩
credentials: {
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
Expand All @@ -45,7 +36,6 @@ export class S3ConfigService {
// 디버깅 로그
console.log('[S3ConfigService] Initialized:');
console.log(' Bucket Name:', this.bucketName);
console.log(' Region:', this.region);
}

getS3Client(): S3Client {
Expand Down

0 comments on commit e4cb13c

Please sign in to comment.