From 4f61942bec7e00531481a25d1aee6defc8e251d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=8D=A8=ED=81=AC?= Date: Tue, 14 Nov 2023 19:02:28 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20s3config=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flory/global/config/S3Config.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/zerobibim/flory/global/config/S3Config.java diff --git a/src/main/java/zerobibim/flory/global/config/S3Config.java b/src/main/java/zerobibim/flory/global/config/S3Config.java new file mode 100644 index 0000000..e7bac4e --- /dev/null +++ b/src/main/java/zerobibim/flory/global/config/S3Config.java @@ -0,0 +1,28 @@ +package zerobibim.flory.global.config; + +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.services.s3.AmazonS3Client; +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; + +@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; + + @Bean + public AmazonS3Client amazonS3Client() { + BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); + return (AmazonS3Client) AmazonS3ClientBuilder.standard() + .withRegion(region) + .withCredentials(new AWSStaticCredentialsProvider(awsCredentials)) + .build(); + } +}