Skip to content

Instantly share code, notes, and snippets.

@billydh
Created January 15, 2020 11:47
Show Gist options
  • Select an option

  • Save billydh/8bdab0255c1f41a26cef5ee0979902d7 to your computer and use it in GitHub Desktop.

Select an option

Save billydh/8bdab0255c1f41a26cef5ee0979902d7 to your computer and use it in GitHub Desktop.
DynamoClientProperties using DynamoConfigProperties
package io.codebrews.dynamodemo
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient
import java.net.URI
@Configuration
class DynamoClientProperties(private val dynamoConfigProperties: DynamoConfigProperties) {
@Bean
fun dynamoDbAsyncClient(): DynamoDbAsyncClient {
return DynamoDbAsyncClient.builder()
.region(Region.of(dynamoConfigProperties.region))
.endpointOverride(URI.create(dynamoConfigProperties.endpoint))
.credentialsProvider(DefaultCredentialsProvider.builder().build())
.build()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment