File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
src/main/java/com/be/sportizebe/global/config Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 44import org .springframework .beans .factory .annotation .Value ;
55import org .springframework .context .annotation .Bean ;
66import 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 ;
89import software .amazon .awssdk .regions .Region ;
910import 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}
You can’t perform that action at this time.
0 commit comments