@Override
  public List<Cluster> listClusters(String accountId, String clusterNamePrefix) {
    if (clusterNamePrefix != null) {
      Validate.notNull(accountId, "accountId must be specified if clusterNamePrefix is specified");
    }

    PaginatedList<EnvironmentDDBRecord> clusters;

    if (accountId == null) {
      clusters =
          dynamoDBMapper.scan(
              EnvironmentDDBRecord.class,
              new DynamoDBScanExpression()
                  .withIndexName(EnvironmentDDBRecord.ENVIRONMENT_CLUSTER_GSI_NAME));
    } else {
      DynamoDBQueryExpression<EnvironmentDDBRecord> query =
          new DynamoDBQueryExpression<EnvironmentDDBRecord>()
              .withIndexName(EnvironmentDDBRecord.ENVIRONMENT_CLUSTER_GSI_NAME)
              .withHashKeyValues(EnvironmentDDBRecord.builder().accountId(accountId).build())
              .withConsistentRead(false);

      if (clusterNamePrefix != null) {
        query.withRangeKeyCondition(
            EnvironmentDDBRecord.ENVIRONMENT_CLUSTER_INDEX_RANGE_KEY,
            new Condition()
                .withComparisonOperator(ComparisonOperator.BEGINS_WITH.toString())
                .withAttributeValueList(new AttributeValue().withS(clusterNamePrefix)));
      }
      clusters = dynamoDBMapper.query(EnvironmentDDBRecord.class, query);
    }

    return clusters
        .stream()
        .map(environmentMapper::toCluster)
        .distinct() // items in the index aren't unique
        .collect(Collectors.toList());
  }
Check if environment revisions exist and clean them up.
data-service/src/main/java/com/amazonaws/blox/dataservice/repository/EnvironmentRepositoryDDB.java