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(); } }