private URL getEc2MetadataServiceUrlForResource(String resourcePath) throws IOException {
        String endpoint = EC2_METADATA_SERVICE_URL;
        if (System.getProperty(EC2_METADATA_SERVICE_OVERRIDE_SYSTEM_PROPERTY) != null) {
            endpoint = System.getProperty(EC2_METADATA_SERVICE_OVERRIDE_SYSTEM_PROPERTY);
        }

        return new URL(endpoint + resourcePath);
    }
Constructs a URL to the EC2 metadata service for the specified
resource path.

@param resourcePath
           The resource portion of the URL.

@return A URL to the EC2 metadata service for the specified resource
        path.

@throws IOException
            If a valid URL could not be constructed.
aws-java-sdk-core/src/main/java/com/amazonaws/internal/EC2MetadataClient.java