From 63179808508ab59aa0867bcedec8d68fd835aeb3 Mon Sep 17 00:00:00 2001 From: ChoiYoungHoon Date: Sat, 2 Dec 2023 23:24:17 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20amazon=20s3=20=EC=A0=91=EA=B7=BC=20?= =?UTF-8?q?=EC=8B=9C=20credentials=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/co/kirikiri/common/config/AWSConfig.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/kirikiri/src/main/java/co/kirikiri/common/config/AWSConfig.java b/backend/kirikiri/src/main/java/co/kirikiri/common/config/AWSConfig.java index b084ee0eb..21500a245 100644 --- a/backend/kirikiri/src/main/java/co/kirikiri/common/config/AWSConfig.java +++ b/backend/kirikiri/src/main/java/co/kirikiri/common/config/AWSConfig.java @@ -1,5 +1,7 @@ package co.kirikiri.common.config; +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.regions.Regions; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3ClientBuilder; @@ -11,15 +13,23 @@ public class AWSConfig { private final Regions region; + private final String accessKey; + private final String secretKey; - public AWSConfig(@Value("${cloud.aws.region.static}") final String region) { + public AWSConfig(@Value("${cloud.aws.region.static}") final String region, + @Value("${cloud.aws.credentials.access-key}") final String accessKey, + @Value("${cloud.aws.credentials.secret-key}") final String secretKey) { this.region = Regions.fromName(region); + this.accessKey = accessKey; + this.secretKey = secretKey; } @Bean public AmazonS3 amazonS3() { + final BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); return AmazonS3ClientBuilder.standard() .withRegion(region) + .withCredentials(new AWSStaticCredentialsProvider(awsCredentials)) .build(); } } From d60758ed15c0832a82a59354a8aa662f4156a9e3 Mon Sep 17 00:00:00 2001 From: ChoiYoungHoon Date: Sun, 3 Dec 2023 17:47:04 +0900 Subject: [PATCH 2/2] =?UTF-8?q?test:=20test=20application.yml=EC=97=90=20c?= =?UTF-8?q?redentials=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/kirikiri/src/test/resources/application.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/kirikiri/src/test/resources/application.yml b/backend/kirikiri/src/test/resources/application.yml index ba48bddbe..54e9cdfd7 100644 --- a/backend/kirikiri/src/test/resources/application.yml +++ b/backend/kirikiri/src/test/resources/application.yml @@ -59,14 +59,15 @@ cloud: stack: auto: false credentials: - instanceProfile: true + access-key: access-key + secret-key: secret-key s3: - bucket: 2023-team-project + bucket: 2023-team-project-kirikiri root-directory: 2023-co-kirikiri sub-directory: prod url-expiration: 60000 cloud-front: - distribution-domain: https://d3pqwmpjbeqywx.cloudfront.net + distribution-domain: https://d3c3ldqehj669c.cloudfront.net oauth: naver: