
driven-adapter.dynamo-db.config.dynamodb-config.mustache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scaffold-clean-architecture Show documentation
Show all versions of scaffold-clean-architecture Show documentation
Gradle plugin to create a clean application in Java that already works, It follows our best practices!
package {{package}}.dynamodb.config;
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;
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.auth.credentials.WebIdentityTokenFileCredentialsProvider;
import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import java.net.URI;
@Configuration
public class DynamoDBConfig {
@Bean
@Profile({"local"})
public DynamoDbClient amazonDynamoDBLocal(@Value("${aws.region}") String region,
@Value("${aws.dynamodb.endpoint}") String endpoint) {
return DynamoDbClient.builder()
.credentialsProvider(ProfileCredentialsProvider.create("default"))
.region(Region.of(region))
.endpointOverride(URI.create(endpoint))
.build();
}
@Bean
@Profile({"dev", "cer", "pdn"})
public DynamoDbClient amazonDynamoDB(@Value("${aws.region}") String region) {
return DynamoDbClient.builder()
.credentialsProvider(WebIdentityTokenFileCredentialsProvider.create())
.region(Region.of(region))
.build();
}
@Bean
public DynamoDbEnhancedClient getDynamoDbEnhancedClient(DynamoDbClient client) {
return DynamoDbEnhancedClient.builder()
.dynamoDbClient(client)
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy