sodalive-backend-spring-boot/src/main/kotlin/kr/co/vividnext/sodalive/configs/AmazonSESConfig.kt

31 lines
1.1 KiB
Kotlin

package kr.co.vividnext.sodalive.configs
import com.amazonaws.auth.AWSStaticCredentialsProvider
import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.services.simpleemail.AmazonSimpleEmailService
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class AmazonSESConfig(
@Value("\${cloud.aws.credentials.access-key}")
private val accessKey: String,
@Value("\${cloud.aws.credentials.secret-key}")
private val secretKey: String,
@Value("\${cloud.aws.region.static}")
private val region: String
) {
@Bean
fun amazonSimpleEmailService(): AmazonSimpleEmailService {
val basicAWSCredentials = BasicAWSCredentials(accessKey, secretKey)
val awsStaticCredentialsProvider = AWSStaticCredentialsProvider(basicAWSCredentials)
return AmazonSimpleEmailServiceClientBuilder.standard()
.withCredentials(awsStaticCredentialsProvider)
.withRegion(region)
.build()
}
}