From 07a2059ee68f165a5d102790a24461cfa2ad7a02 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Thu, 1 Aug 2024 00:57:06 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20aws=20=ED=99=98=EA=B2=BD=EC=97=90=20?= =?UTF-8?q?=EB=A7=9E=EC=B6=94=EC=96=B4=20AmazonS3Client=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=A9=EC=8B=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/few/storage/config/ClientConfig.kt | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/storage/src/main/kotlin/com/few/storage/config/ClientConfig.kt b/storage/src/main/kotlin/com/few/storage/config/ClientConfig.kt index 1c074d889..b95ab3f8a 100644 --- a/storage/src/main/kotlin/com/few/storage/config/ClientConfig.kt +++ b/storage/src/main/kotlin/com/few/storage/config/ClientConfig.kt @@ -8,6 +8,7 @@ import com.amazonaws.services.s3.AmazonS3ClientBuilder import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Profile @Configuration class ClientConfig( @@ -17,8 +18,9 @@ class ClientConfig( @Value("\${storage.region}") val region: String, ) { + @Profile("!prd") @Bean - fun s3StorageClient(): AmazonS3Client { + fun localS3StorageClient(): AmazonS3Client { val builder = AmazonS3ClientBuilder.standard() .withCredentials( AWSStaticCredentialsProvider( @@ -39,4 +41,21 @@ class ClientConfig( return client as AmazonS3Client } } + + @Profile("prd") + @Bean + fun prdS3StorageClient(): AmazonS3Client { + AmazonS3Client.builder() + .withRegion(region) + .withCredentials( + AWSStaticCredentialsProvider( + BasicAWSCredentials( + accessKey, + secretKey + ) + ) + ).build().let { client -> + return client as AmazonS3Client + } + } } \ No newline at end of file