private boolean isAllowedHost(String host) {
            try {
                InetAddress[] addresses = InetAddress.getAllByName(host);
                boolean allAllowed = true;
                for (InetAddress address: addresses) {
                    if (!isLoopbackAddress(address)) {
                        allAllowed = false;
                    }
                }

                return addresses.length > 0 && (allAllowed || isMetadataServiceEndpoint(host));

            } catch (UnknownHostException e) {
                throw new SdkClientException(String.format("host (%s) could not be resolved to an IP address.", host), e);
            }
        }
Determines if the addresses for a given host are resolved to a loopback address.
<p>
    This is a best-effort in determining what address a host will be resolved to. DNS caching might be disabled,
    or could expire between this check and when the API is invoked.
</p>
@param host The name or IP address of the host.
@return A boolean specifying whether the host is allowed as an endpoint for credentials loading.
aws-java-sdk-core/src/main/java/com/amazonaws/auth/ContainerCredentialsProvider.java