code: public static String getSecurityGroupName() throws IOException {
          // For AWS, we are returning the first security group from the list
          // that is obtained by querying the meta-data.
  
          String url = getMetadataUrl() + "/security-groups";
          String groups = invokeUrl(url);
  
          if ((groups == null) || (groups.trim().length() == 0)) {
              String msg = "No security-group assigned to the instance";
              throw new IllegalStateException(msg);
          }
  
          StringTokenizer tokenizer = new StringTokenizer(groups, "\n");
          return tokenizer.nextToken(); // We only need the first one.
      }
docs: Returns the name of the security group from the list that is
  obtained from the resource vendor. An instance may belong to multiple
  security groups. And, the list of security groups obtained from the
  vendor may not be ordered. If the vendor supports the notion of
  a default security group, then that should be returned. Otherwise,
  the implementation will be vendor-specific.
  
  @return
  @throws java.io.IOException