SDK for C++ の例 - AWSSDK コードサンプル

AWSDocAWS SDKGitHub サンプルリポジトリには、さらに多くの SDK サンプルがあります

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

SDK for C++ の例

次のコード例は、AWS SDK for C++ with Aurora を使用してアクションを実行する方法を示しています。

アクション」は、個々のサービス関数の呼び出し方法を示すコードの抜粋です。

シナリオ」は、同じサービス内で複数の関数を呼び出して、特定のタスクを実行する方法を示すコード例です。

それぞれの例にはGitHub、へのリンクがあり、コンテキストでコードを設定および実行する方法についての説明が記載されています。

アクション

次のコード例は、Aurora DB クラスターを作成する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::CreateDBClusterRequest request; request.SetDBClusterIdentifier(DB_CLUSTER_IDENTIFIER); request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); request.SetEngine(engineName); request.SetEngineVersion(engineVersionName); request.SetMasterUsername(administratorName); request.SetMasterUserPassword(administratorPassword); Aws::RDS::Model::CreateDBClusterOutcome outcome = client.CreateDBCluster(request); if (outcome.IsSuccess()) { std::cout << "The DB cluster creation has started." << std::endl; } else { std::cerr << "Error with Aurora::CreateDBCluster. " << outcome.GetError().GetMessage() << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, "", "", client); return false; }
  • API の詳細については、AWS SDK for C++ API リファレンスの「CreateDBCluster」を参照してください。

次のコード例は、Aurora DB クラスターパラメーターグループを作成する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::CreateDBClusterParameterGroupRequest request; request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); request.SetDBParameterGroupFamily(dbParameterGroupFamily); request.SetDescription("Example cluster parameter group."); Aws::RDS::Model::CreateDBClusterParameterGroupOutcome outcome = client.CreateDBClusterParameterGroup(request); if (outcome.IsSuccess()) { std::cout << "The DB cluster parameter group was successfully created." << std::endl; } else { std::cerr << "Error with Aurora::CreateDBClusterParameterGroup. " << outcome.GetError().GetMessage() << std::endl; return false; }
  • API の詳細については、AWS SDK for C++APIClusterParameterGroup リファレンスのCreateDB」を参照してください。

次のコード例は、Aurora DB クラスタースナップショットを作成する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::CreateDBClusterSnapshotRequest request; request.SetDBClusterIdentifier(DB_CLUSTER_IDENTIFIER); request.SetDBClusterSnapshotIdentifier(snapshotID); Aws::RDS::Model::CreateDBClusterSnapshotOutcome outcome = client.CreateDBClusterSnapshot(request); if (outcome.IsSuccess()) { std::cout << "Snapshot creation has started." << std::endl; } else { std::cerr << "Error with Aurora::CreateDBClusterSnapshot. " << outcome.GetError().GetMessage() << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, DB_INSTANCE_IDENTIFIER, client); return false; }
  • API の詳細については、AWS SDK for C++APIClusterSnapshot リファレンスのCreateDB」を参照してください。

次のコード例は、Aurora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora ora

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::CreateDBInstanceRequest request; request.SetDBInstanceIdentifier(DB_INSTANCE_IDENTIFIER); request.SetDBClusterIdentifier(DB_CLUSTER_IDENTIFIER); request.SetEngine(engineName); request.SetDBInstanceClass(dbInstanceClass); Aws::RDS::Model::CreateDBInstanceOutcome outcome = client.CreateDBInstance(request); if (outcome.IsSuccess()) { std::cout << "The DB instance creation has started." << std::endl; } else { std::cerr << "Error with RDS::CreateDBInstance. " << outcome.GetError().GetMessage() << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, "", client); return false; }
  • API の詳細については、AWS SDK for C++ API リファレンスの「CreateDBInstance」を参照してください。

次のコード例は、Aurora DB クラスターを削除する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::DeleteDBClusterRequest request; request.SetDBClusterIdentifier(dbClusterIdentifier); request.SetSkipFinalSnapshot(true); Aws::RDS::Model::DeleteDBClusterOutcome outcome = client.DeleteDBCluster(request); if (outcome.IsSuccess()) { std::cout << "DB cluster deletion has started." << std::endl; clusterDeleting = true; std::cout << "Waiting for DB cluster to delete before deleting the parameter group." << std::endl; std::cout << "This may take a while." << std::endl; } else { std::cerr << "Error with Aurora::DeleteDBCluster. " << outcome.GetError().GetMessage() << std::endl; result = false; }

次のコード例は、Aurora DB クラスターパラメーターグループを削除する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::DeleteDBClusterParameterGroupRequest request; request.SetDBClusterParameterGroupName(parameterGroupName); Aws::RDS::Model::DeleteDBClusterParameterGroupOutcome outcome = client.DeleteDBClusterParameterGroup(request); if (outcome.IsSuccess()) { std::cout << "The DB parameter group was successfully deleted." << std::endl; } else { std::cerr << "Error with Aurora::DeleteDBClusterParameterGroup. " << outcome.GetError().GetMessage() << std::endl; result = false; }
  • API の詳細については、AWS SDK for C++APIClusterParameterGroup リファレンスの DeletedB を参照してください。

次のコード例は、Aurora DB インスタンスを削除する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::DeleteDBInstanceRequest request; request.SetDBInstanceIdentifier(dbInstanceIdentifier); request.SetSkipFinalSnapshot(true); request.SetDeleteAutomatedBackups(true); Aws::RDS::Model::DeleteDBInstanceOutcome outcome = client.DeleteDBInstance(request); if (outcome.IsSuccess()) { std::cout << "DB instance deletion has started." << std::endl; instanceDeleting = true; std::cout << "Waiting for DB instance to delete before deleting the parameter group." << std::endl; } else { std::cerr << "Error with Aurora::DeleteDBInstance. " << outcome.GetError().GetMessage() << std::endl; result = false; }
  • API の詳細については、AWS SDK for C++ API リファレンスの「DeleteDBInstance」を参照してください。

次のコード例は、Aurora DB クラスターパラメーターグループを記述する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::DescribeDBClusterParameterGroupsRequest request; request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); Aws::RDS::Model::DescribeDBClusterParameterGroupsOutcome outcome = client.DescribeDBClusterParameterGroups(request); if (outcome.IsSuccess()) { std::cout << "DB cluster parameter group named '" << CLUSTER_PARAMETER_GROUP_NAME << "' already exists." << std::endl; dbParameterGroupFamily = outcome.GetResult().GetDBClusterParameterGroups()[0].GetDBParameterGroupFamily(); } else { std::cerr << "Error with Aurora::DescribeDBClusterParameterGroups. " << outcome.GetError().GetMessage() << std::endl; return false; }
  • API の詳細については、AWS SDK for C++APIClusterParameterGroups リファレンスのDescribedDB」を参照してください。

次のコード例は、Aurora DB クラスタースナップショットを記述する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::DescribeDBClusterSnapshotsRequest request; request.SetDBClusterSnapshotIdentifier(snapshotID); Aws::RDS::Model::DescribeDBClusterSnapshotsOutcome outcome = client.DescribeDBClusterSnapshots(request); if (outcome.IsSuccess()) { snapshot = outcome.GetResult().GetDBClusterSnapshots()[0]; } else { std::cerr << "Error with Aurora::DescribeDBClusterSnapshots. " << outcome.GetError().GetMessage() << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, DB_INSTANCE_IDENTIFIER, client); return false; }
  • API の詳細については、AWS SDK for C++APIClusterSnapshots リファレンスのDescribedDB」を参照してください。

次のコード例は、Aurora DB クラスターの記述方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

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; }
  • API の詳細については、AWS SDK for C++ API リファレンスの「DescribeDBClusters」を参照してください。

次のコード例は、Aurora DB インスタンスを記述する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

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 instance description. /*! \sa describeDBCluster() \param dbInstanceIdentifier: A DB instance identifier. \param instanceResult: The 'DBInstance' object containing the description. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::describeDBInstance(const Aws::String &dbInstanceIdentifier, Aws::RDS::Model::DBInstance &instanceResult, const Aws::RDS::RDSClient &client) { Aws::RDS::Model::DescribeDBInstancesRequest request; request.SetDBInstanceIdentifier(dbInstanceIdentifier); Aws::RDS::Model::DescribeDBInstancesOutcome outcome = client.DescribeDBInstances(request); bool result = true; if (outcome.IsSuccess()) { instanceResult = outcome.GetResult().GetDBInstances()[0]; } // This example does not log an error if the DB instance does not exist. // Instead, it returns false. else if (outcome.GetError().GetErrorType() != Aws::RDS::RDSErrors::D_B_INSTANCE_NOT_FOUND_FAULT) { result = false; std::cerr << "Error with Aurora::DescribeDBInstances. " << outcome.GetError().GetMessage() << std::endl; } return result; }
  • API の詳細については、AWS SDK for C++ API リファレンスの「DescribeDBInstances」を参照してください。

次のコード例は、Aurora データベースエンジンの記述方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

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 available DB engine versions for an engine name and //! an optional parameter group family. /*! \sa getDBEngineVersions() \param engineName: A DB engine name. \param parameterGroupFamily: A parameter group family name, ignored if empty. \param engineVersionsResult: Vector of 'DBEngineVersion' objects returned by the routine. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::getDBEngineVersions(const Aws::String &engineName, const Aws::String &parameterGroupFamily, Aws::Vector<Aws::RDS::Model::DBEngineVersion> &engineVersionsResult, const Aws::RDS::RDSClient &client) { Aws::RDS::Model::DescribeDBEngineVersionsRequest request; request.SetEngine(engineName); if (!parameterGroupFamily.empty()) { request.SetDBParameterGroupFamily(parameterGroupFamily); } Aws::RDS::Model::DescribeDBEngineVersionsOutcome outcome = client.DescribeDBEngineVersions(request); if (outcome.IsSuccess()) { engineVersionsResult = outcome.GetResult().GetDBEngineVersions(); } else { std::cerr << "Error with Aurora::DescribeDBEngineVersionsRequest. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
  • API の詳細については、AWS SDK for C++APIEngineVersions リファレンスのDescribedDB」を参照してください。

次のコード例は、Aurora インスタンスの記述方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

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 available DB instance classes, displays the list //! to the user, and returns the user selection. /*! \sa chooseDBInstanceClass() \param engineName: The DB engine name. \param engineVersion: The DB engine version. \param dbInstanceClass: String for DB instance class chosen by the user. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::chooseDBInstanceClass(const Aws::String &engine, const Aws::String &engineVersion, Aws::String &dbInstanceClass, const Aws::RDS::RDSClient &client) { std::vector<Aws::String> instanceClasses; Aws::String marker; // The marker is used for pagination. do { Aws::RDS::Model::DescribeOrderableDBInstanceOptionsRequest request; request.SetEngine(engine); request.SetEngineVersion(engineVersion); if (!marker.empty()) { request.SetMarker(marker); } Aws::RDS::Model::DescribeOrderableDBInstanceOptionsOutcome outcome = client.DescribeOrderableDBInstanceOptions(request); if (outcome.IsSuccess()) { const Aws::Vector<Aws::RDS::Model::OrderableDBInstanceOption> &options = outcome.GetResult().GetOrderableDBInstanceOptions(); for (const Aws::RDS::Model::OrderableDBInstanceOption &option: options) { const Aws::String &instanceClass = option.GetDBInstanceClass(); instanceClasses.push_back(instanceClass); } marker = outcome.GetResult().GetMarker(); } else { std::cerr << "Error with Aurora::DescribeOrderableDBInstanceOptions. " << outcome.GetError().GetMessage() << std::endl; return false; } } while (!marker.empty()); std::cout << "The available DB instance classes for your database engine are:" << std::endl; for (int i = 0; i < instanceClasses.size(); ++i) { std::cout << " " << i + 1 << ": " << instanceClasses[i] << std::endl; } int choice = askQuestionForIntRange( "Which DB instance class do you want to use? ", 1, static_cast<int>(instanceClasses.size())); dbInstanceClass = instanceClasses[choice - 1]; return true; }
  • API の詳細については、AWS SDK for C++APIInstanceOptions リファレンスのDescribeOrderable DB を参照してください。

次のコード例は、Aurora DB クラスターパラメーターグループからパラメーターを記述する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

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 DB parameters using the 'DescribeDBClusterParameters' api. /*! \sa getDBCLusterParameters() \param parameterGroupName: The name of the cluster parameter group. \param namePrefix: Prefix string to filter results by parameter name. \param source: A source such as 'user', ignored if empty. \param parametersResult: Vector of 'Parameter' objects returned by the routine. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::getDBCLusterParameters(const Aws::String &parameterGroupName, const Aws::String &namePrefix, const Aws::String &source, Aws::Vector<Aws::RDS::Model::Parameter> &parametersResult, const Aws::RDS::RDSClient &client) { Aws::String marker; // The marker is used for pagination. do { Aws::RDS::Model::DescribeDBClusterParametersRequest request; request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); if (!marker.empty()) { request.SetMarker(marker); } if (!source.empty()) { request.SetSource(source); } Aws::RDS::Model::DescribeDBClusterParametersOutcome outcome = client.DescribeDBClusterParameters(request); if (outcome.IsSuccess()) { const Aws::Vector<Aws::RDS::Model::Parameter> &parameters = outcome.GetResult().GetParameters(); for (const Aws::RDS::Model::Parameter &parameter: parameters) { if (!namePrefix.empty()) { if (parameter.GetParameterName().find(namePrefix) == 0) { parametersResult.push_back(parameter); } } else { parametersResult.push_back(parameter); } } marker = outcome.GetResult().GetMarker(); } else { std::cerr << "Error with Aurora::DescribeDBClusterParameters. " << outcome.GetError().GetMessage() << std::endl; return false; } } while (!marker.empty()); return true; }
  • API の詳細については、AWS SDK for C++APIClusterParameters リファレンスのDescribedDB」を参照してください。

次のコード例は、Aurora DB クラスターパラメーターグループ内のパラメーターを更新する方法を示しています。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::ModifyDBClusterParameterGroupRequest request; request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); request.SetParameters(updateParameters); Aws::RDS::Model::ModifyDBClusterParameterGroupOutcome outcome = client.ModifyDBClusterParameterGroup(request); if (outcome.IsSuccess()) { std::cout << "The DB cluster parameter group was successfully modified." << std::endl; } else { std::cerr << "Error with Aurora::ModifyDBClusterParameterGroup. " << outcome.GetError().GetMessage() << std::endl; }
  • API の詳細については、AWS SDK for C++APIClusterParameterGroup リファレンスのModifyDB」を参照してください。

シナリオ

次のコード例は、以下の操作方法を示しています。

  • カスタム Aurora DB クラスターパラメータグループを作成し、パラメータ値を設定します。

  • パラメータグループを使用する DB クラスターを作成する

  • データベースを含む DB インスタンスを作成します。

  • DB クラスターのスナップショットを作成して、リソースをクリーンアップします。

SDK for C++
注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; //! Routine which creates an Amazon Aurora DB cluster and demonstrates several operations //! on that cluster. /*! \sa gettingStartedWithDBClusters() \param clientConfiguration: AWS client configuration. \return bool: Successful completion. */ bool AwsDoc::Aurora::gettingStartedWithDBClusters( const Aws::Client::ClientConfiguration &clientConfig) { Aws::RDS::RDSClient client(clientConfig); printAsterisksLine(); std::cout << "Welcome to the Amazon Relational Database Service (Amazon Aurora)" << std::endl; std::cout << "get started with DB clusters demo." << std::endl; printAsterisksLine(); std::cout << "Checking for an existing DB cluster parameter group named '" << CLUSTER_PARAMETER_GROUP_NAME << "'." << std::endl; Aws::String dbParameterGroupFamily("Undefined"); bool parameterGroupFound = true; { // 1. Check if the DB cluster parameter group already exists. Aws::RDS::Model::DescribeDBClusterParameterGroupsRequest request; request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); Aws::RDS::Model::DescribeDBClusterParameterGroupsOutcome outcome = client.DescribeDBClusterParameterGroups(request); if (outcome.IsSuccess()) { std::cout << "DB cluster parameter group named '" << CLUSTER_PARAMETER_GROUP_NAME << "' already exists." << std::endl; dbParameterGroupFamily = outcome.GetResult().GetDBClusterParameterGroups()[0].GetDBParameterGroupFamily(); } else if (outcome.GetError().GetErrorType() == Aws::RDS::RDSErrors::D_B_PARAMETER_GROUP_NOT_FOUND_FAULT) { std::cout << "DB cluster parameter group named '" << CLUSTER_PARAMETER_GROUP_NAME << "' does not exist." << std::endl; parameterGroupFound = false; } else { std::cerr << "Error with Aurora::DescribeDBClusterParameterGroups. " << outcome.GetError().GetMessage() << std::endl; return false; } } if (!parameterGroupFound) { Aws::Vector<Aws::RDS::Model::DBEngineVersion> engineVersions; // 2. Get available parameter group families for the specified engine. if (!getDBEngineVersions(DB_ENGINE, NO_PARAMETER_GROUP_FAMILY, engineVersions, client)) { return false; } std::cout << "Getting available parameter group families for " << DB_ENGINE << "." << std::endl; std::vector<Aws::String> families; for (const Aws::RDS::Model::DBEngineVersion &version: engineVersions) { Aws::String family = version.GetDBParameterGroupFamily(); if (std::find(families.begin(), families.end(), family) == families.end()) { families.push_back(family); std::cout << " " << families.size() << ": " << family << std::endl; } } int choice = askQuestionForIntRange("Which family do you want to use? ", 1, static_cast<int>(families.size())); dbParameterGroupFamily = families[choice - 1]; } if (!parameterGroupFound) { // 3. Create a DB cluster parameter group. Aws::RDS::Model::CreateDBClusterParameterGroupRequest request; request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); request.SetDBParameterGroupFamily(dbParameterGroupFamily); request.SetDescription("Example cluster parameter group."); Aws::RDS::Model::CreateDBClusterParameterGroupOutcome outcome = client.CreateDBClusterParameterGroup(request); if (outcome.IsSuccess()) { std::cout << "The DB cluster parameter group was successfully created." << std::endl; } else { std::cerr << "Error with Aurora::CreateDBClusterParameterGroup. " << outcome.GetError().GetMessage() << std::endl; return false; } } printAsterisksLine(); std::cout << "Let's set some parameter values in your cluster parameter group." << std::endl; Aws::Vector<Aws::RDS::Model::Parameter> autoIncrementParameters; // 4. Get the parameters in the DB cluster parameter group. if (!getDBCLusterParameters(CLUSTER_PARAMETER_GROUP_NAME, AUTO_INCREMENT_PREFIX, NO_SOURCE, autoIncrementParameters, client)) { cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, "", "", client); return false; } Aws::Vector<Aws::RDS::Model::Parameter> updateParameters; for (Aws::RDS::Model::Parameter &autoIncParameter: autoIncrementParameters) { if (autoIncParameter.GetIsModifiable() && (autoIncParameter.GetDataType() == "integer")) { std::cout << "The " << autoIncParameter.GetParameterName() << " is described as: " << autoIncParameter.GetDescription() << "." << std::endl; if (autoIncParameter.ParameterValueHasBeenSet()) { std::cout << "The current value is " << autoIncParameter.GetParameterValue() << "." << std::endl; } std::vector<int> splitValues = splitToInts( autoIncParameter.GetAllowedValues(), '-'); if (splitValues.size() == 2) { int newValue = askQuestionForIntRange( Aws::String("Enter a new value between ") + autoIncParameter.GetAllowedValues() + ": ", splitValues[0], splitValues[1]); autoIncParameter.SetParameterValue(std::to_string(newValue)); updateParameters.push_back(autoIncParameter); } else { std::cerr << "Error parsing " << autoIncParameter.GetAllowedValues() << std::endl; } } } { // 5. Modify the auto increment parameters in the DB cluster parameter group. Aws::RDS::Model::ModifyDBClusterParameterGroupRequest request; request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); request.SetParameters(updateParameters); Aws::RDS::Model::ModifyDBClusterParameterGroupOutcome outcome = client.ModifyDBClusterParameterGroup(request); if (outcome.IsSuccess()) { std::cout << "The DB cluster parameter group was successfully modified." << std::endl; } else { std::cerr << "Error with Aurora::ModifyDBClusterParameterGroup. " << outcome.GetError().GetMessage() << std::endl; } } std::cout << "You can get a list of parameters you've set by specifying a source of 'user'." << std::endl; Aws::Vector<Aws::RDS::Model::Parameter> userParameters; // 6. Display the modified parameters in the DB cluster parameter group. if (!getDBCLusterParameters(CLUSTER_PARAMETER_GROUP_NAME, NO_NAME_PREFIX, "user", userParameters, client)) { cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, "", "", client); return false; } for (const auto &userParameter: userParameters) { std::cout << " " << userParameter.GetParameterName() << ", " << userParameter.GetDescription() << ", parameter value - " << userParameter.GetParameterValue() << std::endl; } printAsterisksLine(); std::cout << "Checking for an existing DB Cluster." << std::endl; Aws::RDS::Model::DBCluster dbCluster; // 7. Check if the DB cluster already exists. if (!describeDBCluster(DB_CLUSTER_IDENTIFIER, dbCluster, client)) { cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, "", "", client); return false; } Aws::String engineVersionName; Aws::String engineName; if (dbCluster.DBClusterIdentifierHasBeenSet()) { std::cout << "The DB cluster already exists." << std::endl; engineVersionName = dbCluster.GetEngineVersion(); engineName = dbCluster.GetEngine(); } else { std::cout << "Let's create a DB cluster." << std::endl; const Aws::String administratorName = askQuestion( "Enter an administrator username for the database: "); const Aws::String administratorPassword = askQuestion( "Enter a password for the administrator (at least 8 characters): "); Aws::Vector<Aws::RDS::Model::DBEngineVersion> engineVersions; // 8. Get a list of engine versions for the parameter group family. if (!getDBEngineVersions(DB_ENGINE, dbParameterGroupFamily, engineVersions, client)) { cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, "", "", client); return false; } std::cout << "The available engines for your parameter group family are:" << std::endl; int index = 1; for (const Aws::RDS::Model::DBEngineVersion &engineVersion: engineVersions) { std::cout << " " << index << ": " << engineVersion.GetEngineVersion() << std::endl; ++index; } int choice = askQuestionForIntRange("Which engine do you want to use? ", 1, static_cast<int>(engineVersions.size())); const Aws::RDS::Model::DBEngineVersion engineVersion = engineVersions[choice - 1]; engineName = engineVersion.GetEngine(); engineVersionName = engineVersion.GetEngineVersion(); std::cout << "Creating a DB cluster named '" << DB_CLUSTER_IDENTIFIER << "' and database '" << DB_NAME << "'.\n" << "The DB cluster is configured to use your custom cluster parameter group '" << CLUSTER_PARAMETER_GROUP_NAME << "', and \n" << "selected engine version " << engineVersion.GetEngineVersion() << ".\nThis typically takes several minutes." << std::endl; Aws::RDS::Model::CreateDBClusterRequest request; request.SetDBClusterIdentifier(DB_CLUSTER_IDENTIFIER); request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); request.SetEngine(engineName); request.SetEngineVersion(engineVersionName); request.SetMasterUsername(administratorName); request.SetMasterUserPassword(administratorPassword); Aws::RDS::Model::CreateDBClusterOutcome outcome = client.CreateDBCluster(request); if (outcome.IsSuccess()) { std::cout << "The DB cluster creation has started." << std::endl; } else { std::cerr << "Error with Aurora::CreateDBCluster. " << outcome.GetError().GetMessage() << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, "", "", client); return false; } } std::cout << "Waiting for the DB cluster to become available." << std::endl; int counter = 0; // 11. Wait for the DB cluster to become available. do { std::this_thread::sleep_for(std::chrono::seconds(1)); ++counter; if (counter > 900) { std::cerr << "Wait for cluster to become available timed out ofter " << counter << " seconds." << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, "", client); return false; } dbCluster = Aws::RDS::Model::DBCluster(); if (!describeDBCluster(DB_CLUSTER_IDENTIFIER, dbCluster, client)) { cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, "", client); return false; } if ((counter % 20) == 0) { std::cout << "Current DB cluster status is '" << dbCluster.GetStatus() << "' after " << counter << " seconds." << std::endl; } } while (dbCluster.GetStatus() != "available"); if (dbCluster.GetStatus() == "available") { std::cout << "The DB cluster has been created." << std::endl; } printAsterisksLine(); Aws::RDS::Model::DBInstance dbInstance; // 11. Check if the DB instance already exists. if (!describeDBInstance(DB_INSTANCE_IDENTIFIER, dbInstance, client)) { cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, "", client); return false; } if (dbInstance.DbInstancePortHasBeenSet()) { std::cout << "The DB instance already exists." << std::endl; } else { std::cout << "Let's create a DB instance." << std::endl; Aws::String dbInstanceClass; // 12. Get a list of instance classes. if (!chooseDBInstanceClass(engineName, engineVersionName, dbInstanceClass, client)) { cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, "", client); return false; } std::cout << "Creating a DB instance named '" << DB_INSTANCE_IDENTIFIER << "' with selected DB instance class '" << dbInstanceClass << "'.\nThis typically takes several minutes." << std::endl; // 13. Create a DB instance. Aws::RDS::Model::CreateDBInstanceRequest request; request.SetDBInstanceIdentifier(DB_INSTANCE_IDENTIFIER); request.SetDBClusterIdentifier(DB_CLUSTER_IDENTIFIER); request.SetEngine(engineName); request.SetDBInstanceClass(dbInstanceClass); Aws::RDS::Model::CreateDBInstanceOutcome outcome = client.CreateDBInstance(request); if (outcome.IsSuccess()) { std::cout << "The DB instance creation has started." << std::endl; } else { std::cerr << "Error with RDS::CreateDBInstance. " << outcome.GetError().GetMessage() << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, "", client); return false; } } std::cout << "Waiting for the DB instance to become available." << std::endl; counter = 0; // 14. Wait for the DB instance to become available. do { std::this_thread::sleep_for(std::chrono::seconds(1)); ++counter; if (counter > 900) { std::cerr << "Wait for instance to become available timed out ofter " << counter << " seconds." << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, DB_INSTANCE_IDENTIFIER, client); return false; } dbInstance = Aws::RDS::Model::DBInstance(); if (!describeDBInstance(DB_INSTANCE_IDENTIFIER, dbInstance, client)) { cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, DB_INSTANCE_IDENTIFIER, client); return false; } if ((counter % 20) == 0) { std::cout << "Current DB instance status is '" << dbInstance.GetDBInstanceStatus() << "' after " << counter << " seconds." << std::endl; } } while (dbInstance.GetDBInstanceStatus() != "available"); if (dbInstance.GetDBInstanceStatus() == "available") { std::cout << "The DB instance has been created." << std::endl; } // 15. Display the connection string that can be used to connect a 'mysql' shell to the database. displayConnection(dbCluster); printAsterisksLine(); if (askYesNoQuestion( "Do you want to create a snapshot of your DB cluster (y/n)? ")) { Aws::String snapshotID(DB_CLUSTER_IDENTIFIER + "-" + Aws::String(Aws::Utils::UUID::RandomUUID())); { std::cout << "Creating a snapshot named " << snapshotID << "." << std::endl; std::cout << "This typically takes a few minutes." << std::endl; // 16. Create a snapshot of the DB cluster. (CreateDBClusterSnapshot) Aws::RDS::Model::CreateDBClusterSnapshotRequest request; request.SetDBClusterIdentifier(DB_CLUSTER_IDENTIFIER); request.SetDBClusterSnapshotIdentifier(snapshotID); Aws::RDS::Model::CreateDBClusterSnapshotOutcome outcome = client.CreateDBClusterSnapshot(request); if (outcome.IsSuccess()) { std::cout << "Snapshot creation has started." << std::endl; } else { std::cerr << "Error with Aurora::CreateDBClusterSnapshot. " << outcome.GetError().GetMessage() << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, DB_INSTANCE_IDENTIFIER, client); return false; } } std::cout << "Waiting for the snapshot to become available." << std::endl; Aws::RDS::Model::DBClusterSnapshot snapshot; counter = 0; do { std::this_thread::sleep_for(std::chrono::seconds(1)); ++counter; if (counter > 600) { std::cerr << "Wait for snapshot to be available timed out ofter " << counter << " seconds." << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, DB_INSTANCE_IDENTIFIER, client); return false; } // 17. Wait for the snapshot to become available. Aws::RDS::Model::DescribeDBClusterSnapshotsRequest request; request.SetDBClusterSnapshotIdentifier(snapshotID); Aws::RDS::Model::DescribeDBClusterSnapshotsOutcome outcome = client.DescribeDBClusterSnapshots(request); if (outcome.IsSuccess()) { snapshot = outcome.GetResult().GetDBClusterSnapshots()[0]; } else { std::cerr << "Error with Aurora::DescribeDBClusterSnapshots. " << outcome.GetError().GetMessage() << std::endl; cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, DB_INSTANCE_IDENTIFIER, client); return false; } if ((counter % 20) == 0) { std::cout << "Current snapshot status is '" << snapshot.GetStatus() << "' after " << counter << " seconds." << std::endl; } } while (snapshot.GetStatus() != "available"); if (snapshot.GetStatus() != "available") { std::cout << "A snapshot has been created." << std::endl; } } printAsterisksLine(); bool result = true; if (askYesNoQuestion( "Do you want to delete the DB cluster, DB instance, and parameter group (y/n)? ")) { result = cleanUpResources(CLUSTER_PARAMETER_GROUP_NAME, DB_CLUSTER_IDENTIFIER, DB_INSTANCE_IDENTIFIER, client); } return result; } //! 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; } //! Routine which gets DB parameters using the 'DescribeDBClusterParameters' api. /*! \sa getDBCLusterParameters() \param parameterGroupName: The name of the cluster parameter group. \param namePrefix: Prefix string to filter results by parameter name. \param source: A source such as 'user', ignored if empty. \param parametersResult: Vector of 'Parameter' objects returned by the routine. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::getDBCLusterParameters(const Aws::String &parameterGroupName, const Aws::String &namePrefix, const Aws::String &source, Aws::Vector<Aws::RDS::Model::Parameter> &parametersResult, const Aws::RDS::RDSClient &client) { Aws::String marker; // The marker is used for pagination. do { Aws::RDS::Model::DescribeDBClusterParametersRequest request; request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); if (!marker.empty()) { request.SetMarker(marker); } if (!source.empty()) { request.SetSource(source); } Aws::RDS::Model::DescribeDBClusterParametersOutcome outcome = client.DescribeDBClusterParameters(request); if (outcome.IsSuccess()) { const Aws::Vector<Aws::RDS::Model::Parameter> &parameters = outcome.GetResult().GetParameters(); for (const Aws::RDS::Model::Parameter &parameter: parameters) { if (!namePrefix.empty()) { if (parameter.GetParameterName().find(namePrefix) == 0) { parametersResult.push_back(parameter); } } else { parametersResult.push_back(parameter); } } marker = outcome.GetResult().GetMarker(); } else { std::cerr << "Error with Aurora::DescribeDBClusterParameters. " << outcome.GetError().GetMessage() << std::endl; return false; } } while (!marker.empty()); return true; } //! Routine which gets available DB engine versions for an engine name and //! an optional parameter group family. /*! \sa getDBEngineVersions() \param engineName: A DB engine name. \param parameterGroupFamily: A parameter group family name, ignored if empty. \param engineVersionsResult: Vector of 'DBEngineVersion' objects returned by the routine. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::getDBEngineVersions(const Aws::String &engineName, const Aws::String &parameterGroupFamily, Aws::Vector<Aws::RDS::Model::DBEngineVersion> &engineVersionsResult, const Aws::RDS::RDSClient &client) { Aws::RDS::Model::DescribeDBEngineVersionsRequest request; request.SetEngine(engineName); if (!parameterGroupFamily.empty()) { request.SetDBParameterGroupFamily(parameterGroupFamily); } Aws::RDS::Model::DescribeDBEngineVersionsOutcome outcome = client.DescribeDBEngineVersions(request); if (outcome.IsSuccess()) { engineVersionsResult = outcome.GetResult().GetDBEngineVersions(); } else { std::cerr << "Error with Aurora::DescribeDBEngineVersionsRequest. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); } //! Routine which gets a DB instance description. /*! \sa describeDBCluster() \param dbInstanceIdentifier: A DB instance identifier. \param instanceResult: The 'DBInstance' object containing the description. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::describeDBInstance(const Aws::String &dbInstanceIdentifier, Aws::RDS::Model::DBInstance &instanceResult, const Aws::RDS::RDSClient &client) { Aws::RDS::Model::DescribeDBInstancesRequest request; request.SetDBInstanceIdentifier(dbInstanceIdentifier); Aws::RDS::Model::DescribeDBInstancesOutcome outcome = client.DescribeDBInstances(request); bool result = true; if (outcome.IsSuccess()) { instanceResult = outcome.GetResult().GetDBInstances()[0]; } // This example does not log an error if the DB instance does not exist. // Instead, it returns false. else if (outcome.GetError().GetErrorType() != Aws::RDS::RDSErrors::D_B_INSTANCE_NOT_FOUND_FAULT) { result = false; std::cerr << "Error with Aurora::DescribeDBInstances. " << outcome.GetError().GetMessage() << std::endl; } return result; } //! Routine which gets available DB instance classes, displays the list //! to the user, and returns the user selection. /*! \sa chooseDBInstanceClass() \param engineName: The DB engine name. \param engineVersion: The DB engine version. \param dbInstanceClass: String for DB instance class chosen by the user. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::chooseDBInstanceClass(const Aws::String &engine, const Aws::String &engineVersion, Aws::String &dbInstanceClass, const Aws::RDS::RDSClient &client) { std::vector<Aws::String> instanceClasses; Aws::String marker; // The marker is used for pagination. do { Aws::RDS::Model::DescribeOrderableDBInstanceOptionsRequest request; request.SetEngine(engine); request.SetEngineVersion(engineVersion); if (!marker.empty()) { request.SetMarker(marker); } Aws::RDS::Model::DescribeOrderableDBInstanceOptionsOutcome outcome = client.DescribeOrderableDBInstanceOptions(request); if (outcome.IsSuccess()) { const Aws::Vector<Aws::RDS::Model::OrderableDBInstanceOption> &options = outcome.GetResult().GetOrderableDBInstanceOptions(); for (const Aws::RDS::Model::OrderableDBInstanceOption &option: options) { const Aws::String &instanceClass = option.GetDBInstanceClass(); instanceClasses.push_back(instanceClass); } marker = outcome.GetResult().GetMarker(); } else { std::cerr << "Error with Aurora::DescribeOrderableDBInstanceOptions. " << outcome.GetError().GetMessage() << std::endl; return false; } } while (!marker.empty()); std::cout << "The available DB instance classes for your database engine are:" << std::endl; for (int i = 0; i < instanceClasses.size(); ++i) { std::cout << " " << i + 1 << ": " << instanceClasses[i] << std::endl; } int choice = askQuestionForIntRange( "Which DB instance class do you want to use? ", 1, static_cast<int>(instanceClasses.size())); dbInstanceClass = instanceClasses[choice - 1]; return true; } //! Routine which deletes resources created by the scenario. /*! \sa cleanUpResources() \param parameterGroupName: A parameter group name, this may be empty. \param dbInstanceIdentifier: A DB instance identifier, this may be empty. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::cleanUpResources(const Aws::String &parameterGroupName, const Aws::String &dbClusterIdentifier, const Aws::String &dbInstanceIdentifier, const Aws::RDS::RDSClient &client) { bool result = true; bool instanceDeleting = false; bool clusterDeleting = false; if (!dbInstanceIdentifier.empty()) { { // 18. Delete the DB instance. Aws::RDS::Model::DeleteDBInstanceRequest request; request.SetDBInstanceIdentifier(dbInstanceIdentifier); request.SetSkipFinalSnapshot(true); request.SetDeleteAutomatedBackups(true); Aws::RDS::Model::DeleteDBInstanceOutcome outcome = client.DeleteDBInstance(request); if (outcome.IsSuccess()) { std::cout << "DB instance deletion has started." << std::endl; instanceDeleting = true; std::cout << "Waiting for DB instance to delete before deleting the parameter group." << std::endl; } else { std::cerr << "Error with Aurora::DeleteDBInstance. " << outcome.GetError().GetMessage() << std::endl; result = false; } } } if (!dbClusterIdentifier.empty()) { { // 19. Delete the DB cluster. Aws::RDS::Model::DeleteDBClusterRequest request; request.SetDBClusterIdentifier(dbClusterIdentifier); request.SetSkipFinalSnapshot(true); Aws::RDS::Model::DeleteDBClusterOutcome outcome = client.DeleteDBCluster(request); if (outcome.IsSuccess()) { std::cout << "DB cluster deletion has started." << std::endl; clusterDeleting = true; std::cout << "Waiting for DB cluster to delete before deleting the parameter group." << std::endl; std::cout << "This may take a while." << std::endl; } else { std::cerr << "Error with Aurora::DeleteDBCluster. " << outcome.GetError().GetMessage() << std::endl; result = false; } } } int counter = 0; while (clusterDeleting || instanceDeleting) { // 20. Wait for the DB cluster and instance to be deleted. std::this_thread::sleep_for(std::chrono::seconds(1)); ++counter; if (counter > 800) { std::cerr << "Wait for instance to delete timed out ofter " << counter << " seconds." << std::endl; return false; } Aws::RDS::Model::DBInstance dbInstance = Aws::RDS::Model::DBInstance(); if (instanceDeleting) { if (!describeDBInstance(dbInstanceIdentifier, dbInstance, client)) { return false; } instanceDeleting = dbInstance.DBInstanceIdentifierHasBeenSet(); } Aws::RDS::Model::DBCluster dbCluster = Aws::RDS::Model::DBCluster(); if (clusterDeleting) { if (!describeDBCluster(dbClusterIdentifier, dbCluster, client)) { return false; } clusterDeleting = dbCluster.DBClusterIdentifierHasBeenSet(); } if ((counter % 20) == 0) { if (instanceDeleting) { std::cout << "Current DB instance status is '" << dbInstance.GetDBInstanceStatus() << "." << std::endl; } if (clusterDeleting) { std::cout << "Current DB cluster status is '" << dbCluster.GetStatus() << "." << std::endl; } } } if (!parameterGroupName.empty()) { // 21. Delete the DB cluster parameter group. Aws::RDS::Model::DeleteDBClusterParameterGroupRequest request; request.SetDBClusterParameterGroupName(parameterGroupName); Aws::RDS::Model::DeleteDBClusterParameterGroupOutcome outcome = client.DeleteDBClusterParameterGroup(request); if (outcome.IsSuccess()) { std::cout << "The DB parameter group was successfully deleted." << std::endl; } else { std::cerr << "Error with Aurora::DeleteDBClusterParameterGroup. " << outcome.GetError().GetMessage() << std::endl; result = false; } } return result; }