private synchronized List<ContentXml> getAndCacheIndex(PlanetilerConfig config) {
    if (entries.isEmpty()) {
      List<ContentXml> result = new ArrayList<>();
      String nextPageParam = "";
      int pageNum = 0;
      do {
        try (InputStream inputStream = Downloader.openStream(bucketIndexUrl + "?list-type=2" + nextPageParam, config)) {
          if (pageNum++ > MAX_PAGES) {
            throw new IllegalArgumentException("Too many entries in " + bucketIndexUrl + " to page through");
          }
          var page = parseIndexXml(inputStream);
          result.addAll(page.contents());
          nextPageParam = (!page.truncated() || page.nextToken() == null) ? null :
            "&continuation-token=" + URLEncoder.encode(page.nextToken(), StandardCharsets.UTF_8);
        } catch (IOException e) {
          throw new IllegalStateException(e);
        }
      } while (nextPageParam != null);
      entries.addAll(result);
    }
    return entries;
  }
Fetches the S3 bucket index and searches for a {@code .osm.pbf} resource to download where snapshot date matches
{@code searchQuery}, or the latest snapshot if {@code searchQuery == "latest"}.
<p>
The index is only fetched once and cached after that.

@param searchQuery the snapshot to search for
@param config      planetiler config with user-agent and timeout to use when downloading
@return the URL of a {@code .osm.pbf} file with name or snapshot ID matching {@code searchQuery}
@throws IllegalArgumentException if no matches, or more than one match is found.
planetiler-core/src/main/java/com/onthegomap/planetiler/util/AwsOsm.java