Spring configuration property name for AWS SDK for Java v2 starts with aws2.<service-name>
.
Set aws2.<service-name>.region
as the property of Spring Boot.
DynamoDbClient dynamoDB = DynamoDbClient.builder()
.region(Region.EU_CENTRAL_1)
.build();
The DynamoDB client equivalent to the above can be registered as follows:
aws2.dynamodb.region=eu-central-1
@Configuration
@EnableAwsClientV2(DynamoDbClient.class)
static class ExampleRegionConfiguration {
}
Set aws2.<service-name>.endpoint
as the property of Spring Boot.
SnsClient snsClient = SnsClient.builder()
.endpointOverride(URI.create("http://localhost:4569"))
.build();
The SNS client equivalent to the above can be registered as follows:
aws2.sns.endpoint=http://localhost:4569
@Configuration
@EnableAwsClientV2(SnsClient.class)
static class ExampleEndpointConfiguration {
}
Set aws2.<service-name>.credentials-provider-bean-name
as the property of Spring Boot.
It is required to register AwsCredentialsProvider
bean.
StaticCredentialsProvider credProvider = StaticCredentialsProvider
.create(AwsBasicCredentials
.create("...", "..."));
SqsClient sqsClient = SqsClient.builder()
.credentialsProvider(credProvider)
.build();
The SQS client equivalent to the above can be registered as follows:
aws2.sqs.credentials-provider-bean-name=sqsCredentialsProvider
@Configuration
@EnableAwsClientV2(SqsClient.class)
static class ExampleCredentialsProviderConfiguration {
@Bean
public AwsCredentialsProvider sqsCredentialsProvider() {
return StaticCredentialsProvider
.create(AwsBasicCredentials.create("...", "..."));
}
}
Set aws2.<service-name>.http-client-builder-bean-name
as the property of Spring Boot.
It is required to register SdkHttpClient.Builder
bean for sync-client.
If you want to register async-client, you should register SdkAsyncHttpClient.Builder
bean.
SdkHttpClient.Builder builder = ApacheHttpClient.builder()
.connectionTimeout(Duration.ofMinutes(2500))
.socketTimeout(Duration.ofSeconds(25));
SesClient sqsClient = SesClient.builder()
.httpClientBuilder(builder)
.build();
The SES client equivalent to the above can be registered as follows:
aws2.ses.http-client-builder-bean-name=sesHttpClientBuilder
@Configuration
@EnableAwsClientV2(SesClient.class)
static class ExampleHttpClientBuilderConfiguration {
@Bean
public SdkHttpClient.Builder sesHttpClientBuilder() {
return ApacheHttpClient.builder()
.connectionTimeout(Duration.ofMillis(2500))
.socketTimeout(Duration.ofSeconds(25));
}
}
Set aws2.<service-name>-async.*
as the property of Spring Boot.
aws2.<service-name>.*
does not affect to async client configuration.
aws2.sqs.client.region=us-east-1
aws2.sqs-async.region=eu-central-1
In this case, the region for SqsClient
is us-east-1
,
and the region for SqsAsyncClient
is eu-central-1
.
Set aws2.s3.*
as the property of Spring Boot.
aws2.s3.path-style-access-enabled=true
aws2.s3.chunked-encoding-enabled=true
aws2.s3.accelerate-mode-enabled=false
aws2.s3.dualstack-enabled=true
aws2.s3.checksum-validation-enabled=true
For details, see the javadoc of S3Configuration
.