3
3
import org .springframework .beans .factory .annotation .Value ;
4
4
import org .springframework .context .annotation .Bean ;
5
5
import org .springframework .context .annotation .Configuration ;
6
- import software .amazon .awssdk .auth .credentials .AwsBasicCredentials ;
7
- import software .amazon .awssdk .auth .credentials .AwsCredentials ;
8
- import software .amazon .awssdk .auth .credentials .AwsCredentialsProvider ;
9
- import software .amazon .awssdk .auth .credentials .StaticCredentialsProvider ;
10
6
import software .amazon .awssdk .regions .Region ;
11
7
import software .amazon .awssdk .services .s3 .S3Client ;
12
8
import software .amazon .awssdk .services .s3 .presigner .S3Presigner ;
13
9
14
10
@ Configuration
15
11
public class S3Config {
16
-
17
- @ Value ("${cloud.aws.credentials.access-key}" )
18
- private String accessKey ;
19
-
20
- @ Value ("${cloud.aws.credentials.secret-key}" )
21
- private String secretKey ;
22
-
23
12
@ Value ("${cloud.aws.region.static}" )
24
13
private String region ;
25
14
26
- // access, secret key 이용해 aws 자격증명 제공
27
- @ Bean
28
- public AwsCredentialsProvider awsCredentialsProvider () {
29
- AwsCredentials awsCredentials = AwsBasicCredentials .create (accessKey , secretKey );
30
- return StaticCredentialsProvider .create (awsCredentials );
31
- }
32
-
33
15
// s3서비스를 이용하기 위한 S3Client 객체 생성
34
16
@ Bean
35
17
public S3Client s3Client () {
36
18
return S3Client .builder ()
37
19
.region (Region .of (region ))
38
- .credentialsProvider (awsCredentialsProvider ())
39
20
.build ();
40
21
}
41
22
@@ -44,7 +25,6 @@ public S3Client s3Client() {
44
25
public S3Presigner s3Presigner () {
45
26
return S3Presigner .builder ()
46
27
.region (Region .of (region ))
47
- .credentialsProvider (awsCredentialsProvider ())
48
28
.build ();
49
29
}
50
30
}
0 commit comments