I have a RDS database cluster with 1 instance and no DocumentDB cluster. But when I tried to list the DocumentDB cluster via API, such as
AmazonDocDB docdb= AmazonDocDBClientBuilder.standard().withRegion(Regions.EU_WEST_1).withCredentials(new AWSStaticCredentialsProvider(credentials)).build();
for(DBCluster db : docdb.describeDBClusters(new DescribeDBClustersRequest()).getDBClusters()) {
System.out.println(db);
}
it will return the information of the RDS database cluster, which is wrong in my opinion. The question is how can I list DocumentDB cluster without showing the RDS database cluster (which in this case would be none)?
Please, consider review the javadocs of the describeDBClusters
method:
Returns information about provisioned Amazon DocumentDB clusters. This API operation supports pagination. For certain management features such as cluster and instance lifecycle management, Amazon DocumentDB leverages operational technology that is shared with Amazon RDS and Amazon Neptune. Use the
filterName=engine,Values=docdb
filter parameter to return only Amazon DocumentDB clusters.
I assume, although it is unclear in the javadocs and the API description, that you can provide the required filter in your DescribeDBClustersRequest
with something like:
AmazonDocDB docdb= AmazonDocDBClientBuilder.standard().withRegion(Regions.EU_WEST_1).withCredentials(new AWSStaticCredentialsProvider(credentials)).build();
Filter filter = new Filter()
.withName("engine")
.withValues("docdb");
DescribeDBClustersRequest request = new DescribeDBClustersRequest()
.withFilters(filter);
for(DBCluster db : docdb.describeDBClusters(request).getDBClusters()) {
System.out.println(db);
}