-
Notifications
You must be signed in to change notification settings - Fork 937
Closed
Labels
bugThis issue is a bug.This issue is a bug.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.
Description
Describe the bug
I switched to AWS SDK 2 where the region
is set as Region
enum in the builders, and not the creation of Sns throws the following exception.
Caused by: software.amazon.awssdk.core.exception.SdkClientException: Configured region (EU_CENTRAL_1) and tags ([]) resulted in an invalid URI: https://sns.EU_CENTRAL_1.amazonaws.com. This is usually caused by an invalid region configuration. Valid regions: [af-south-1, ap-east-1, ap-northeast-1, ap-northeast-2, ap-northeast-3, ap-south-1, ap-south-2, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-4, ap-southeast-5, ap-southeast-7, ca-central-1, ca-west-1, eu-central-1, eu-central-2, eu-north-1, eu-south-1, eu-south-2, eu-west-1, eu-west-2, eu-west-3, fips-us-east-1, fips-us-east-2, fips-us-west-1, fips-us-west-2, il-central-1, me-central-1, me-south-1, mx-central-1, sa-east-1, us-east-1, us-east-2, us-west-1, us-west-2, cn-north-1, cn-northwest-1, fips-us-gov-east-1, fips-us-gov-west-1, us-gov-east-1, us-gov-west-1, us-iso-east-1, us-iso-west-1, us-isob-east-1, eu-isoe-west-1, us-isof-east-1, us-isof-south-1]
at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:130) ~[sdk-core-2.31.54.jar:?]
at software.amazon.awssdk.core.exception.SdkClientException.create(SdkClientException.java:43) ~[sdk-core-2.31.54.jar:?]
at software.amazon.awssdk.awscore.endpoint.AwsClientEndpointProvider.clientEndpointFromServiceMetadata(AwsClientEndpointProvider.java:252) ~[aws-core-2.31.54.jar:?]
at software.amazon.awssdk.awscore.endpoint.AwsClientEndpointProvider.lambda$resolveClientEndpoint$2(AwsClientEndpointProvider.java:100) ~[aws-core-2.31.54.jar:?]
at software.amazon.awssdk.utils.OptionalUtils.firstPresent(OptionalUtils.java:47) ~[utils-2.31.54.jar:?]
at software.amazon.awssdk.awscore.endpoint.AwsClientEndpointProvider.resolveClientEndpoint(AwsClientEndpointProvider.java:98) ~[aws-core-2.31.54.jar:?]
at software.amazon.awssdk.awscore.endpoint.AwsClientEndpointProvider.lambda$new$0(AwsClientEndpointProvider.java:73) ~[aws-core-2.31.54.jar:?]
at software.amazon.awssdk.utils.Lazy.getValue(Lazy.java:50) ~[utils-2.31.54.jar:?]
at software.amazon.awssdk.awscore.endpoint.AwsClientEndpointProvider.isEndpointOverridden(AwsClientEndpointProvider.java:94) ~[aws-core-2.31.54.jar:?]
at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.resolveEndpointOverridden(AwsDefaultClientBuilder.java:356) ~[aws-core-2.31.54.jar:?]
at software.amazon.awssdk.utils.AttributeMap$DerivedValue.primeCache(AttributeMap.java:604) ~[utils-2.31.54.jar:?]
at software.amazon.awssdk.utils.AttributeMap$DerivedValue.get(AttributeMap.java:593) ~[utils-2.31.54.jar:?]
at software.amazon.awssdk.utils.AttributeMap$Builder.resolveValue(AttributeMap.java:400) ~[utils-2.31.54.jar:?]
at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?]
at software.amazon.awssdk.utils.AttributeMap$Builder.build(AttributeMap.java:362) ~[utils-2.31.54.jar:?]
at software.amazon.awssdk.core.client.config.SdkClientConfiguration$Builder.build(SdkClientConfiguration.java:224) ~[sdk-core-2.31.54.jar:?]
at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.finalizeAwsConfiguration(AwsDefaultClientBuilder.java:201) ~[aws-core-2.31.54.jar:?]
at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.finalizeChildConfiguration(AwsDefaultClientBuilder.java:172) ~[aws-core-2.31.54.jar:?]
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.asyncClientConfiguration(SdkDefaultClientBuilder.java:233) ~[sdk-core-2.31.54.jar:?]
at software.amazon.awssdk.services.sns.DefaultSnsAsyncClientBuilder.buildClient(DefaultSnsAsyncClientBuilder.java:37) ~[sns-2.31.54.jar:?]
at software.amazon.awssdk.services.sns.DefaultSnsAsyncClientBuilder.buildClient(DefaultSnsAsyncClientBuilder.java:25) ~[sns-2.31.54.jar:?]
at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.build(SdkDefaultClientBuilder.java:169) ~[sdk-core-2.31.54.jar:?]
The configuration code looks like this:
@Bean
@Primary
public AwsCredentialsProvider snsCredentialsProvider(SnsTopicsConfigurationProperty configuration) {
StsClient stsClient = StsClient
.builder()
.region(Region.EU_CENTRAL_1)
.build();
return StsAssumeRoleCredentialsProvider
.builder()
.stsClient(stsClient)
.refreshRequest(r -> r
.roleArn(configuration.getStsRoleArn())
.roleSessionName(STS_ROLE_SESSION_NAME)
)
.asyncCredentialUpdateEnabled(true) // Use a background thread to prefetch credentials.
.build();
}
and it's called from
return SnsAsyncClient
.builder()
.credentialsProvider(snsCredentialsProvider(configuration)) // we need to assume role to call SNS:ListTopics on other account
.region(Region.EU_CENTRAL_1)
.build();
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
Region is correctly parsed to eu-central-1
, builders are working.
Current Behavior
Exception fails, although the region is set as the enum value Region.EU_CENTRAL_1
.
Reproduction Steps
Execute the code as listed above.
Library version is 2.32.4
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.32.4
JDK version used
JDK 19
Operating System and version
Windows 11
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.