Use DeleteDBParameterGroup with an Amazon SDK or CLI - Amazon Relational Database Service
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).

Use DeleteDBParameterGroup with an Amazon SDK or CLI

The following code examples show how to use DeleteDBParameterGroup.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

.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> /// Delete a DB parameter group. The group cannot be a default DB parameter group /// or be associated with any DB instances. /// </summary> /// <param name="name">Name of the DB parameter group.</param> /// <returns>True if successful.</returns> public async Task<bool> DeleteDBParameterGroup(string name) { var response = await _amazonRDS.DeleteDBParameterGroupAsync( new DeleteDBParameterGroupRequest() { DBParameterGroupName = name, }); return response.HttpStatusCode == HttpStatusCode.OK; }
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::DeleteDBParameterGroupRequest request; request.SetDBParameterGroupName(parameterGroupName); Aws::RDS::Model::DeleteDBParameterGroupOutcome outcome = client.DeleteDBParameterGroup(request); if (outcome.IsSuccess()) { std::cout << "The DB parameter group was successfully deleted." << std::endl; } else { std::cerr << "Error with RDS::DeleteDBParameterGroup. " << outcome.GetError().GetMessage() << std::endl; result = false; }
CLI
Amazon CLI

To delete a DB parameter group

The following command example deletes a DB parameter group.

aws rds delete-db-parameter-group \ --db-parameter-group-name mydbparametergroup

This command produces no output.

For more information, see Working with DB Parameter Groups in the Amazon RDS User Guide.

Go
SDK for Go V2
Note

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

type DbInstances struct { RdsClient *rds.Client } // DeleteParameterGroup deletes the named DB parameter group. func (instances *DbInstances) DeleteParameterGroup(parameterGroupName string) error { _, err := instances.RdsClient.DeleteDBParameterGroup(context.TODO(), &rds.DeleteDBParameterGroupInput{ DBParameterGroupName: aws.String(parameterGroupName), }) if err != nil { log.Printf("Couldn't delete parameter group %v: %v\n", parameterGroupName, err) return err } else { return nil } }
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.

// Delete the parameter group after database has been deleted. // An exception is thrown if you attempt to delete the para group while database // exists. public static void deleteParaGroup(RdsClient rdsClient, String dbGroupName, String dbARN) throws InterruptedException { try { boolean isDataDel = false; boolean didFind; String instanceARN; // Make sure that the database has been deleted. while (!isDataDel) { DescribeDbInstancesResponse response = rdsClient.describeDBInstances(); List<DBInstance> instanceList = response.dbInstances(); int listSize = instanceList.size(); didFind = false; int index = 1; for (DBInstance instance : instanceList) { instanceARN = instance.dbInstanceArn(); if (instanceARN.compareTo(dbARN) == 0) { System.out.println(dbARN + " still exists"); didFind = true; } if ((index == listSize) && (!didFind)) { // Went through the entire list and did not find the database ARN. isDataDel = true; } Thread.sleep(sleepTime * 1000); index++; } } // Delete the para group. DeleteDbParameterGroupRequest parameterGroupRequest = DeleteDbParameterGroupRequest.builder() .dbParameterGroupName(dbGroupName) .build(); rdsClient.deleteDBParameterGroup(parameterGroupRequest); System.out.println(dbGroupName + " was deleted."); } catch (RdsException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
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 InstanceWrapper: """Encapsulates Amazon RDS DB instance actions.""" def __init__(self, rds_client): """ :param rds_client: A Boto3 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 delete_parameter_group(self, parameter_group_name): """ Deletes a DB parameter group. :param parameter_group_name: The name of the parameter group to delete. :return: Data about the parameter group. """ try: self.rds_client.delete_db_parameter_group( DBParameterGroupName=parameter_group_name ) except ClientError as err: logger.error( "Couldn't delete parameter group %s. Here's why: %s: %s", parameter_group_name, err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise

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.