Skip to content

Commit

Permalink
[feat/CK-239] Amazon S3 접근 시 credential 정보를 이용하도록 수정한다 (#201)
Browse files Browse the repository at this point in the history
* feat: amazon s3 접근 시 credentials 사용하도록 수정

* test: test application.yml에 credentials 추가
  • Loading branch information
younghoondoodoom authored Dec 3, 2023
1 parent f79f929 commit 53ea50f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
}
}
7 changes: 4 additions & 3 deletions backend/kirikiri/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 53ea50f

Please sign in to comment.