Skip to content
Snippets Groups Projects
Commit 0203be66 authored by Clément CORNU's avatar Clément CORNU
Browse files

feat: change db config to use application.yaml values

parent 75f0e95a
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -2,17 +2,28 @@ package betclic.test.configuration
import io.ktor.server.config.*
import org.slf4j.LoggerFactory
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedAsyncClient
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient
import java.net.URI
private const val APPLICATION_YAML = "application.yaml"
class DynamoDbConfiguration {
private val logger = LoggerFactory.getLogger(DynamoDbConfiguration::class.java)
fun createDynamoDbClient(): DynamoDbAsyncClient {
val url = ApplicationConfig("application.yaml").property("ktor.database.dynamodbUrl").getString()
val url = ApplicationConfig(APPLICATION_YAML).property("ktor.database.dynamodbUrl").getString()
val accessKey = ApplicationConfig(APPLICATION_YAML).property("ktor.database.accessKey").getString()
val secretKey = ApplicationConfig(APPLICATION_YAML).property("ktor.database.secretKey").getString()
return DynamoDbAsyncClient.builder()
.endpointOverride(URI(url))
.region(Region.US_EAST_1)
.credentialsProvider(
StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, secretKey))
)
.build()
}
......
......@@ -6,3 +6,5 @@ ktor:
port: 8080
database:
dynamodbUrl: "http://localhost:8000"
accessKey: "dummy"
secretKey: "dummy"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment