Skip to content

Commit 0b69dcc

Browse files
committed
🐛Fix: aws 자격증명 설정 StaticCredentialsProvider으로 변경
1 parent ce725b1 commit 0b69dcc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/main/java/com/be/sportizebe/global/config/S3Config.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import org.springframework.beans.factory.annotation.Value;
55
import org.springframework.context.annotation.Bean;
66
import org.springframework.context.annotation.Configuration;
7-
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
7+
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
8+
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
89
import software.amazon.awssdk.regions.Region;
910
import software.amazon.awssdk.services.s3.S3Client;
1011

@@ -21,11 +22,21 @@ public class S3Config {
2122
@Value("${spring.cloud.aws.s3.path.club}")
2223
private String club;
2324

25+
@Value("${spring.cloud.aws.credentials.access-key}")
26+
private String accessKey;
27+
28+
@Value("${spring.cloud.aws.credentials.secret-key}")
29+
private String secretKey;
30+
2431
@Bean
2532
S3Client s3Client() {
33+
AwsBasicCredentials credentials = AwsBasicCredentials.create(accessKey, secretKey);
34+
2635
return S3Client.builder()
2736
.region(Region.AP_NORTHEAST_2)
28-
.credentialsProvider(DefaultCredentialsProvider.create())
37+
// DefaultCredentialsProvider: 환경 변수나 AWS 프로필 파일에서 자격 증명을 찾음
38+
// StaticCredentialsProvider: 개발환경에서는 application.yml에서 찾도록 설정
39+
.credentialsProvider(StaticCredentialsProvider.create(credentials))
2940
.build();
3041
}
3142
}

0 commit comments

Comments
 (0)