@Override
  public List<Environment> listEnvironments(
      @NonNull final Cluster cluster, final String environmentNamePrefix)
      throws InternalServiceException {
    try {
      final DynamoDBQueryExpression<EnvironmentDDBRecord> queryExpression =
          new DynamoDBQueryExpression<EnvironmentDDBRecord>()
              .withHashKeyValues(
                  EnvironmentDDBRecord.withHashKeys(cluster.generateAccountIdCluster()));
      if (environmentNamePrefix != null) {
        queryExpression.withRangeKeyCondition(
            ENVIRONMENT_NAME_RANGE_KEY,
            new Condition()
                .withComparisonOperator(ComparisonOperator.BEGINS_WITH)
                .withAttributeValueList(new AttributeValue().withS(environmentNamePrefix)));
      }
      return dynamoDBMapper
          .query(EnvironmentDDBRecord.class, queryExpression)
          .stream()
          .map(environmentMapper::toEnvironment)
          .collect(Collectors.toList());
    } catch (final AmazonServiceException e) {
      throw new InternalServiceException(
          String.format("Could not query environments for cluster %s", cluster.toString()), e);
    }
  }
Check if environment revisions exist and clean them up.
data-service/src/main/java/com/amazonaws/blox/dataservice/repository/EnvironmentRepositoryDDB.java