code: public static String decodeCloudId(String cloudId) {
          // 1. Ignore anything before `:`.
          String id = cloudId.substring(cloudId.indexOf(':') + 1);
  
          // 2. base64 decode
          String decoded = new String(Base64.getDecoder().decode(id));
  
          // 3. separate based on `$`
          String[] words = decoded.split("\\$");
  
          // 4. form the URLs
          return "https://" + words[1] + "." + words[0] + ":443";
      }
docs: Decode a cloudId to a Node representation. This helps when using
  official elasticsearch as a service: https://cloud.elastic.co
  The cloudId can be found from the cloud console.
  
  @param cloudId The cloud ID to decode.
  @return A Node running on https://address:443