Created
November 10, 2020 05:24
-
-
Save billydh/fd4c3e55abf13f9097d95ee6e1cb1ea8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.context.annotation.Bean | |
import org.springframework.context.annotation.Configuration | |
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider | |
import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedAsyncClient | |
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() | |
} | |
@Bean | |
fun dynamoDbEnhancedAsyncClient(): DynamoDbEnhancedAsyncClient { | |
return DynamoDbEnhancedAsyncClient.builder() | |
.dynamoDbClient(dynamoDbAsyncClient()) | |
.build() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment