in core/aws-core/src/main/java/software/amazon/awssdk/awscore/endpoint/DefaultServiceEndpointBuilder.java [99:158]
public URI getServiceEndpoint() {
if (profileFile == null) {
profileFile = new Lazy<>(ProfileFile::defaultProfileFile)::getValue;
}
if (profileName == null) {
profileName = ProfileFileSystemSetting.AWS_PROFILE.getStringValueOrThrow();
}
if (dualstackEnabled == null) {
dualstackEnabled = DualstackEnabledProvider.builder()
.profileFile(profileFile)
.profileName(profileName)
.build()
.isDualstackEnabled()
.orElse(false);
}
if (fipsEnabled == null) {
fipsEnabled = FipsEnabledProvider.builder()
.profileFile(profileFile)
.profileName(profileName)
.build()
.isFipsEnabled()
.orElse(false);
}
List<EndpointTag> endpointTags = new ArrayList<>();
if (dualstackEnabled) {
endpointTags.add(EndpointTag.DUALSTACK);
}
if (fipsEnabled) {
endpointTags.add(EndpointTag.FIPS);
}
ServiceMetadata serviceMetadata = ServiceMetadata.of(serviceName)
.reconfigure(c -> c.profileFile(profileFile)
.profileName(profileName)
.advancedOptions(advancedOptions));
URI endpoint = addProtocolToServiceEndpoint(serviceMetadata.endpointFor(ServiceEndpointKey.builder()
.region(region)
.tags(endpointTags)
.build()));
if (endpoint.getHost() == null) {
String error = "Configured region (" + region + ") and tags (" + endpointTags + ") resulted in an invalid URI: "
+ endpoint + ". This is usually caused by an invalid region configuration.";
List<Region> exampleRegions = serviceMetadata.regions();
if (!exampleRegions.isEmpty()) {
error += " Valid regions: " + exampleRegions;
}
throw SdkClientException.create(error);
}
return endpoint;
}