Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat/CK-239] Amazon S3 접근 시 credential 정보를 이용하도록 수정한다 #201

Merged
merged 2 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading