Describe Aurora DB clusters using an Amazon SDK - Amazon Aurora
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Describe Aurora DB clusters using an Amazon SDK

The following code examples show how to describe Aurora DB clusters.

.NET
Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <summary> /// Returns a list of DB clusters. /// </summary> /// <param name="dbInstanceIdentifier">Optional name of a specific DB cluster.</param> /// <returns>List of DB clusters.</returns> public async Task<List<DBCluster>> DescribeDBClustersPagedAsync(string? dbClusterIdentifier = null) { var results = new List<DBCluster>(); DescribeDBClustersResponse response; DescribeDBClustersRequest request = new DescribeDBClustersRequest { DBClusterIdentifier = dbClusterIdentifier }; // Get the full list if there are multiple pages. do { response = await _amazonRDS.DescribeDBClustersAsync(request); results.AddRange(response.DBClusters); request.Marker = response.Marker; } while (response.Marker is not null); return results; }
C++
SDK for C++
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); //! Routine which gets a DB cluster description. /*! \sa describeDBCluster() \param dbClusterIdentifier: A DB cluster identifier. \param clusterResult: The 'DBCluster' object containing the description. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::describeDBCluster(const Aws::String &dbClusterIdentifier, Aws::RDS::Model::DBCluster &clusterResult, const Aws::RDS::RDSClient &client) { Aws::RDS::Model::DescribeDBClustersRequest request; request.SetDBClusterIdentifier(dbClusterIdentifier); Aws::RDS::Model::DescribeDBClustersOutcome outcome = client.DescribeDBClusters(request); bool result = true; if (outcome.IsSuccess()) { clusterResult = outcome.GetResult().GetDBClusters()[0]; } // This example does not log an error if the DB cluster does not exist. // Instead, it returns false. else if (outcome.GetError().GetErrorType() != Aws::RDS::RDSErrors::D_B_CLUSTER_NOT_FOUND_FAULT) { result = false; std::cerr << "Error with Aurora::GDescribeDBClusters. " << outcome.GetError().GetMessage() << std::endl; } return result; }
Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

public static void describeDbClusterParameters(RdsClient rdsClient, String dbCLusterGroupName, int flag) { try { DescribeDbClusterParametersRequest dbParameterGroupsRequest; if (flag == 0) { dbParameterGroupsRequest = DescribeDbClusterParametersRequest.builder() .dbClusterParameterGroupName(dbCLusterGroupName) .build(); } else { dbParameterGroupsRequest = DescribeDbClusterParametersRequest.builder() .dbClusterParameterGroupName(dbCLusterGroupName) .source("user") .build(); } DescribeDbClusterParametersResponse response = rdsClient.describeDBClusterParameters(dbParameterGroupsRequest); List<Parameter> dbParameters = response.parameters(); String paraName; for (Parameter para: dbParameters) { // Only print out information about either auto_increment_offset or auto_increment_increment. paraName = para.parameterName(); if ( (paraName.compareTo("auto_increment_offset") ==0) || (paraName.compareTo("auto_increment_increment ") ==0)) { System.out.println("*** The parameter name is " + paraName); System.out.println("*** The parameter value is " + para.parameterValue()); System.out.println("*** The parameter data type is " + para.dataType()); System.out.println("*** The parameter description is " + para.description()); System.out.println("*** The parameter allowed values is " + para.allowedValues()); } } } catch (RdsException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
Kotlin
SDK for Kotlin
Note

This is prerelease documentation for a feature in preview release. It is subject to change.

Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

suspend fun describeDbClusterParameters(dbCLusterGroupName: String?, flag: Int) { val dbParameterGroupsRequest: DescribeDbClusterParametersRequest dbParameterGroupsRequest = if (flag == 0) { DescribeDbClusterParametersRequest { dbClusterParameterGroupName = dbCLusterGroupName } } else { DescribeDbClusterParametersRequest { dbClusterParameterGroupName = dbCLusterGroupName source = "user" } } RdsClient { region = "us-west-2" }.use { rdsClient -> val response = rdsClient.describeDbClusterParameters(dbParameterGroupsRequest) response.parameters?.forEach { para -> // Only print out information about either auto_increment_offset or auto_increment_increment. val paraName = para.parameterName if (paraName != null) { if (paraName.compareTo("auto_increment_offset") == 0 || paraName.compareTo("auto_increment_increment ") == 0) { println("*** The parameter name is $paraName") println("*** The parameter value is ${para.parameterValue}") println("*** The parameter data type is ${para.dataType}") println("*** The parameter description is ${para.description}") println("*** The parameter allowed values is ${para.allowedValues}") } } } } }
Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

class AuroraWrapper: """Encapsulates Aurora DB cluster actions.""" def __init__(self, rds_client): """ :param rds_client: A Boto3 Amazon Relational Database Service (Amazon RDS) client. """ self.rds_client = rds_client @classmethod def from_client(cls): """ Instantiates this class from a Boto3 client. """ rds_client = boto3.client('rds') return cls(rds_client) def get_db_cluster(self, cluster_name): """ Gets data about an Aurora DB cluster. :param cluster_name: The name of the DB cluster to retrieve. :return: The retrieved DB cluster. """ try: response = self.rds_client.describe_db_clusters( DBClusterIdentifier=cluster_name) cluster = response['DBClusters'][0] except ClientError as err: if err.response['Error']['Code'] == 'DBClusterNotFoundFault': logger.info("Cluster %s does not exist.", cluster_name) else: logger.error( "Couldn't verify the existence of DB cluster %s. Here's why: %s: %s", cluster_name, err.response['Error']['Code'], err.response['Error']['Message']) raise else: return cluster

For a complete list of Amazon SDK developer guides and code examples, see Using this service with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.