Update parameters in an Aurora DB cluster parameter group using an Amazon SDK
The following code examples show how to update parameters in an Aurora DB cluster parameter group.
- .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> /// Modify the specified integer parameters with new values from user input. /// </summary> /// <param name="groupName">The group name for the parameters.</param> /// <param name="parameters">The list of integer parameters to modify.</param> /// <param name="newValue">Optional int value to set for parameters.</param> /// <returns>The name of the group that was modified.</returns> public async Task<string> ModifyIntegerParametersInGroupAsync(string groupName, List<Parameter> parameters, int newValue = 0) { foreach (var p in parameters) { if (p.IsModifiable && p.DataType == "integer") { while (newValue == 0) { Console.WriteLine( $"Enter a new value for {p.ParameterName} from the allowed values {p.AllowedValues} "); var choice = Console.ReadLine(); int.TryParse(choice, out newValue); } p.ParameterValue = newValue.ToString(); } } var request = new ModifyDBClusterParameterGroupRequest { Parameters = parameters, DBClusterParameterGroupName = groupName, }; var result = await _amazonRDS.ModifyDBClusterParameterGroupAsync(request); return result.DBClusterParameterGroupName; }
-
For API details, see ModifyDBClusterParameterGroup in Amazon SDK for .NET API Reference.
-
- 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); 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; }
-
For API details, see ModifyDBClusterParameterGroup in Amazon SDK for C++ API Reference.
-
- 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 describeDbClusterParameterGroups(RdsClient rdsClient, String dbClusterGroupName) { try { DescribeDbClusterParameterGroupsRequest groupsRequest = DescribeDbClusterParameterGroupsRequest.builder() .dbClusterParameterGroupName(dbClusterGroupName) .maxRecords(20) .build(); List<DBClusterParameterGroup> groups = rdsClient.describeDBClusterParameterGroups(groupsRequest).dbClusterParameterGroups(); for (DBClusterParameterGroup group: groups) { System.out.println("The group name is "+group.dbClusterParameterGroupName()); System.out.println("The group ARN is "+group.dbClusterParameterGroupArn()); } } catch (RdsException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
-
For API details, see ModifyDBClusterParameterGroup in Amazon SDK for Java 2.x API Reference.
-
- 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
. // Modify the auto_increment_offset parameter. suspend fun modifyDBClusterParas(dClusterGroupName: String?) { val parameter1 = Parameter { parameterName = "auto_increment_offset" applyMethod = ApplyMethod.fromValue("immediate") parameterValue = "5" } val paraList = ArrayList<Parameter>() paraList.add(parameter1) val groupRequest = ModifyDbClusterParameterGroupRequest { dbClusterParameterGroupName = dClusterGroupName parameters = paraList } RdsClient { region = "us-west-2" }.use { rdsClient -> val response = rdsClient.modifyDbClusterParameterGroup(groupRequest) println("The parameter group ${response.dbClusterParameterGroupName} was successfully modified") } }
-
For API details, see ModifyDBClusterParameterGroup
in Amazon SDK for Kotlin API reference.
-
- 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 update_parameters(self, parameter_group_name, update_parameters): """ Updates parameters in a custom DB cluster parameter group. :param parameter_group_name: The name of the parameter group to update. :param update_parameters: The parameters to update in the group. :return: Data about the modified parameter group. """ try: response = self.rds_client.modify_db_cluster_parameter_group( DBClusterParameterGroupName=parameter_group_name, Parameters=update_parameters) except ClientError as err: logger.error( "Couldn't update parameters in %s. Here's why: %s: %s", parameter_group_name, err.response['Error']['Code'], err.response['Error']['Message']) raise else: return response
-
For API details, see ModifyDBClusterParameterGroup in Amazon SDK for Python (Boto3) API Reference.
-
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.