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

        for (Region region : getRegions()) {
            for (String serviceEndpoint :
                region.getAvailableEndpoints()) {

                if (host.equals(getHost(serviceEndpoint))) {
                    return region;
                }
            }
        }

        throw new IllegalArgumentException(
            "No region found with any service for endpoint " + endpoint);
    }
An abstract implementation of {@link RegionMetadataProvider}
aws-java-sdk-core/src/main/java/com/amazonaws/regions/AbstractRegionMetadataProvider.java