code: public String readResource(String resourcePath) throws IOException, SdkClientException {
          URL url = getEc2MetadataServiceUrlForResource(resourcePath);
          log.debug("Connecting to EC2 instance metadata service at URL: " + url.toString());
  
          HttpURLConnection connection = (HttpURLConnection)url.openConnection();
          connection.setConnectTimeout(1000 * 2);
          connection.setReadTimeout(1000 * 5);
          connection.setRequestMethod("GET");
          connection.setDoOutput(true);
          connection.addRequestProperty("User-Agent", USER_AGENT);
          connection.connect();
  
          return readResponse(connection);
      }
docs: Connects to the metadata service to read the specified resource and
  returns the text contents.
  
  @param resourcePath
  The resource
  
  @return The text payload returned from the Amazon EC2 Instance Metadata
  service for the specified resource path.
  
  @throws IOException
  If any problems were encountered while connecting to metadata
  service for the requested resource path.
  @throws SdkClientException
  If the requested metadata service is not found.