@Override
    public Region tryGetRegionByEndpointDnsSuffix(String endpoint) {
        String host = getHost(endpoint);

        for (String dnsSuffix : standardHostnamePatternDnsSuffixes) {
            dnsSuffix = "." + dnsSuffix;

            // This host name ends with a DNS suffix of a specific partition
            // Assume it matches the partition hostname pattern
            if (host.endsWith(dnsSuffix)) {
                String serviceRegion = host.substring(0, host.length() - dnsSuffix.length());
                String region = serviceRegion.substring(serviceRegion.lastIndexOf('.') + 1);

                if (region.isEmpty()) {
                    return null;
                }

                // We don't use the partition that matched the DNS suffix because multiple partitions can have the same DNS
                // suffix. Now that we think we have a region out of the host name, make sure it's in the endpoints.json and
                // attach the associated partition that region is actually under.
                return getRegion(region);
            }
        }

        return null;
    }
Region metadata provider based on partitions.
aws-java-sdk-core/src/main/java/com/amazonaws/partitions/PartitionMetadataProvider.java