-
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.
- Loading branch information
Showing
2 changed files
with
57 additions
and
23 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/main/java/site/katchup/katchupserver/external/s3/AWSConfig.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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package site.katchup.katchupserver.external.s3; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
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.SystemPropertyCredentialsProvider; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.s3.S3Client; | ||
import software.amazon.awssdk.services.s3.presigner.S3Presigner; | ||
|
||
|
||
@Configuration | ||
public class AWSConfig { | ||
|
||
@Value("${cloud.aws.credentials.accessKey}") | ||
private String accessKey; | ||
@Value("${cloud.aws.credentials.secretKey}") | ||
private String secretKey; | ||
|
||
@Value("${cloud.aws.region.static}") | ||
private String regionString; | ||
|
||
@PostConstruct | ||
public void setEnv() { | ||
System.setProperty("aws.accessKeyId", accessKey); | ||
System.setProperty("aws.secretAccessKey", secretKey); | ||
} | ||
|
||
@Bean | ||
public Region getRegion() { | ||
return Region.of(regionString); | ||
} | ||
|
||
@Bean | ||
S3Presigner getS3Presigner() { | ||
return S3Presigner.builder() | ||
.region(getRegion()) | ||
.credentialsProvider(SystemPropertyCredentialsProvider.create()) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
S3Client getS3Client() { | ||
return S3Client.builder() | ||
.region(getRegion()) | ||
.credentialsProvider(SystemPropertyCredentialsProvider.create()) | ||
.build(); | ||
} | ||
} |
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