Skip to content

Commit

Permalink
fix: aws 환경에 맞추어 AmazonS3Client 생성 방식 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 committed Jul 31, 2024
1 parent 32c9107 commit 07a2059
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion storage/src/main/kotlin/com/few/storage/config/ClientConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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
import org.springframework.context.annotation.Profile

@Configuration
class ClientConfig(
Expand All @@ -17,8 +18,9 @@ class ClientConfig(
@Value("\${storage.region}") val region: String,
) {

@Profile("!prd")
@Bean
fun s3StorageClient(): AmazonS3Client {
fun localS3StorageClient(): AmazonS3Client {
val builder = AmazonS3ClientBuilder.standard()
.withCredentials(
AWSStaticCredentialsProvider(
Expand All @@ -39,4 +41,21 @@ class ClientConfig(
return client as AmazonS3Client
}
}

@Profile("prd")
@Bean
fun prdS3StorageClient(): AmazonS3Client {
AmazonS3Client.builder()
.withRegion(region)
.withCredentials(
AWSStaticCredentialsProvider(
BasicAWSCredentials(
accessKey,
secretKey
)
)
).build().let { client ->
return client as AmazonS3Client
}
}
}

0 comments on commit 07a2059

Please sign in to comment.