
driven-adapter.s3-reactive.s3-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}}.s3.config;
import {{package}}.s3.config.model.S3ConnectionProperties;
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;
{{#metrics}}
import software.amazon.awssdk.metrics.MetricPublisher;
{{/metrics}}
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3AsyncClient;
import java.net.URI;
@Configuration
public class S3Config {
{{^metrics}}
@Profile({"dev", "cer", "pdn"})
@Bean
public S3AsyncClient s3AsyncClient(S3ConnectionProperties s3Properties) {
return S3AsyncClient.builder()
.region(Region.of(s3Properties.getRegion()))
.build();
}
@Profile("local")
@Bean
public S3AsyncClient localS3AsyncClient(S3ConnectionProperties s3Properties) {
return S3AsyncClient.builder()
.region(Region.of(s3Properties.getRegion()))
.credentialsProvider(ProfileCredentialsProvider.create("default"))
.endpointOverride(URI.create(s3Properties.getEndpoint()))
.build();
}
{{/metrics}}
{{#metrics}}
@Profile({"dev", "cer", "pdn"})
@Bean
public S3AsyncClient s3AsyncClient(S3ConnectionProperties s3Properties, MetricPublisher publisher) {
return S3AsyncClient.builder()
.overrideConfiguration(o -> o.addMetricPublisher(publisher))
.region(Region.of(s3Properties.getRegion()))
.build();
}
@Profile("local")
@Bean
public S3AsyncClient localS3AsyncClient(S3ConnectionProperties s3Properties,
MetricPublisher publisher) {
return S3AsyncClient.builder()
.overrideConfiguration(o -> o.addMetricPublisher(publisher))
.region(Region.of(s3Properties.getRegion()))
.credentialsProvider(ProfileCredentialsProvider.create("default"))
.endpointOverride(URI.create(s3Properties.getEndpoint()))
.build();
}
{{/metrics}}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy