|
1 | 1 | package acc.hotsix.file_share.global.config;
|
2 | 2 |
|
3 |
| -import org.springframework.beans.factory.annotation.Value; |
4 | 3 | import org.springframework.context.annotation.Bean;
|
5 | 4 | 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; |
| 5 | +import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; |
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 |
| - @Value("${cloud.aws.region.static}") |
24 |
| - private String region; |
25 |
| - |
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 | 12 | // s3서비스를 이용하기 위한 S3Client 객체 생성
|
34 | 13 | @Bean
|
35 | 14 | public S3Client s3Client() {
|
36 | 15 | return S3Client.builder()
|
37 |
| - .region(Region.of(region)) |
38 |
| - .credentialsProvider(awsCredentialsProvider()) |
| 16 | + .region(Region.AP_NORTHEAST_2) |
| 17 | + .credentialsProvider(DefaultCredentialsProvider.create()) |
39 | 18 | .build();
|
40 | 19 | }
|
41 | 20 |
|
42 | 21 | // presignedURL 을 적용하기 위한 S3Presigner 객체 생성
|
43 | 22 | @Bean
|
44 | 23 | public S3Presigner s3Presigner() {
|
45 | 24 | return S3Presigner.builder()
|
46 |
| - .region(Region.of(region)) |
47 |
| - .credentialsProvider(awsCredentialsProvider()) |
| 25 | + .region(Region.AP_NORTHEAST_2) |
| 26 | + .credentialsProvider(DefaultCredentialsProvider.create()) |
48 | 27 | .build();
|
49 | 28 | }
|
50 | 29 | }
|
0 commit comments