-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: dockerFile, github action 코드 수정
- Loading branch information
Showing
2 changed files
with
28 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 26 additions & 5 deletions
31
src/main/java/acc/hotsix/file_share/global/config/S3Config.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,50 @@ | ||
package acc.hotsix.file_share.global.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; | ||
import software.amazon.awssdk.auth.credentials.AwsCredentials; | ||
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.s3.S3Client; | ||
import software.amazon.awssdk.services.s3.presigner.S3Presigner; | ||
|
||
@Configuration | ||
public class S3Config { | ||
|
||
@Value("${cloud.aws.credentials.access-key}") | ||
private String accessKey; | ||
|
||
@Value("${cloud.aws.credentials.secret-key}") | ||
private String secretKey; | ||
|
||
@Value("${cloud.aws.region.static}") | ||
private String region; | ||
|
||
// access, secret key 이용해 aws 자격증명 제공 | ||
@Bean | ||
public AwsCredentialsProvider awsCredentialsProvider() { | ||
AwsCredentials awsCredentials = AwsBasicCredentials.create(accessKey, secretKey); | ||
return StaticCredentialsProvider.create(awsCredentials); | ||
} | ||
|
||
// s3서비스를 이용하기 위한 S3Client 객체 생성 | ||
@Bean | ||
public S3Client s3Client() { | ||
return S3Client.builder() | ||
.region(Region.AP_NORTHEAST_2) | ||
.credentialsProvider(DefaultCredentialsProvider.create()) | ||
.region(Region.of(region)) | ||
.credentialsProvider(awsCredentialsProvider()) | ||
.build(); | ||
} | ||
|
||
// presignedURL 을 적용하기 위한 S3Presigner 객체 생성 | ||
@Bean | ||
public S3Presigner s3Presigner() { | ||
return S3Presigner.builder() | ||
.region(Region.AP_NORTHEAST_2) | ||
.credentialsProvider(DefaultCredentialsProvider.create()) | ||
.region(Region.of(region)) | ||
.credentialsProvider(awsCredentialsProvider()) | ||
.build(); | ||
} | ||
} |