Use DescribeDBParameterGroups
with an AWS SDK or CLI
The following code examples show how to use DescribeDBParameterGroups
.
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
-
- AWS SDK for .NET
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. /// <summary> /// Get descriptions of DB parameter groups. /// </summary> /// <param name="name">Optional name of the DB parameter group to describe.</param> /// <returns>The list of DB parameter group descriptions.</returns> public async Task<List<DBParameterGroup>> DescribeDBParameterGroups(string name = null) { var response = await _amazonRDS.DescribeDBParameterGroupsAsync( new DescribeDBParameterGroupsRequest() { DBParameterGroupName = name }); return response.DBParameterGroups; }
-
For API details, see DescribeDBParameterGroups in AWS 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 AWS 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::DescribeDBParameterGroupsRequest request; request.SetDBParameterGroupName(PARAMETER_GROUP_NAME); Aws::RDS::Model::DescribeDBParameterGroupsOutcome outcome = client.DescribeDBParameterGroups(request); if (outcome.IsSuccess()) { std::cout << "DB parameter group named '" << PARAMETER_GROUP_NAME << "' already exists." << std::endl; dbParameterGroupFamily = outcome.GetResult().GetDBParameterGroups()[0].GetDBParameterGroupFamily(); } else { std::cerr << "Error with RDS::DescribeDBParameterGroups. " << outcome.GetError().GetMessage() << std::endl; return false; }
-
For API details, see DescribeDBParameterGroups in AWS SDK for C++ API Reference.
-
- CLI
-
- AWS CLI
-
To describe your DB parameter group
The following
describe-db-parameter-groups
example retrieves details about your DB parameter groups.aws rds describe-db-parameter-groups
Output:
{ "DBParameterGroups": [ { "DBParameterGroupName": "default.aurora-mysql5.7", "DBParameterGroupFamily": "aurora-mysql5.7", "Description": "Default parameter group for aurora-mysql5.7", "DBParameterGroupArn": "arn:aws:rds:us-east-1:123456789012:pg:default.aurora-mysql5.7" }, { "DBParameterGroupName": "default.aurora-postgresql9.6", "DBParameterGroupFamily": "aurora-postgresql9.6", "Description": "Default parameter group for aurora-postgresql9.6", "DBParameterGroupArn": "arn:aws:rds:us-east-1:123456789012:pg:default.aurora-postgresql9.6" }, { "DBParameterGroupName": "default.aurora5.6", "DBParameterGroupFamily": "aurora5.6", "Description": "Default parameter group for aurora5.6", "DBParameterGroupArn": "arn:aws:rds:us-east-1:123456789012:pg:default.aurora5.6" }, { "DBParameterGroupName": "default.mariadb10.1", "DBParameterGroupFamily": "mariadb10.1", "Description": "Default parameter group for mariadb10.1", "DBParameterGroupArn": "arn:aws:rds:us-east-1:123456789012:pg:default.mariadb10.1" }, ...some output truncated... ] }
For more information, see Working with DB Parameter Groups in the Amazon RDS User Guide.
-
For API details, see DescribeDBParameterGroups
in AWS CLI Command Reference.
-
- 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 AWS Code Examples Repository
. import ( "context" "errors" "log" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/rds" "github.com/aws/aws-sdk-go-v2/service/rds/types" ) type DbInstances struct { RdsClient *rds.Client } // GetParameterGroup gets a DB parameter group by name. func (instances *DbInstances) GetParameterGroup(ctx context.Context, parameterGroupName string) ( *types.DBParameterGroup, error) { output, err := instances.RdsClient.DescribeDBParameterGroups( ctx, &rds.DescribeDBParameterGroupsInput{ DBParameterGroupName: aws.String(parameterGroupName), }) if err != nil { var notFoundError *types.DBParameterGroupNotFoundFault if errors.As(err, ¬FoundError) { log.Printf("Parameter group %v does not exist.\n", parameterGroupName) err = nil } else { log.Printf("Error getting parameter group %v: %v\n", parameterGroupName, err) } return nil, err } else { return &output.DBParameterGroups[0], err } }
-
For API details, see DescribeDBParameterGroups
in AWS SDK for Go 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 AWS Code Examples Repository
. public static void describeDbParameterGroups(RdsClient rdsClient, String dbGroupName) { try { DescribeDbParameterGroupsRequest groupsRequest = DescribeDbParameterGroupsRequest.builder() .dbParameterGroupName(dbGroupName) .maxRecords(20) .build(); DescribeDbParameterGroupsResponse response = rdsClient.describeDBParameterGroups(groupsRequest); List<DBParameterGroup> groups = response.dbParameterGroups(); for (DBParameterGroup group : groups) { System.out.println("The group name is " + group.dbParameterGroupName()); System.out.println("The group description is " + group.description()); } } catch (RdsException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
-
For API details, see DescribeDBParameterGroups in AWS SDK for Java 2.x 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 AWS 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 get_parameter_group(self, parameter_group_name): """ Gets a DB parameter group. :param parameter_group_name: The name of the parameter group to retrieve. :return: The parameter group. """ try: response = self.rds_client.describe_db_parameter_groups( DBParameterGroupName=parameter_group_name ) parameter_group = response["DBParameterGroups"][0] except ClientError as err: if err.response["Error"]["Code"] == "DBParameterGroupNotFound": logger.info("Parameter group %s does not exist.", parameter_group_name) else: logger.error( "Couldn't get parameter group %s. Here's why: %s: %s", parameter_group_name, err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return parameter_group
-
For API details, see DescribeDBParameterGroups in AWS SDK for Python (Boto3) API Reference.
-
- Ruby
-
- SDK for Ruby
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. require 'aws-sdk-rds' # v2: require 'aws-sdk' # List all Amazon Relational Database Service (Amazon RDS) parameter groups. # # @param rds_resource [Aws::RDS::Resource] An SDK for Ruby Amazon RDS resource. # @return [Array, nil] List of all parameter groups, or nil if error. def list_parameter_groups(rds_resource) parameter_groups = [] rds_resource.db_parameter_groups.each do |p| parameter_groups.append({ "name": p.db_parameter_group_name, "description": p.description }) end parameter_groups rescue Aws::Errors::ServiceError => e puts "Couldn't list parameter groups:\n #{e.message}" end
-
For API details, see DescribeDBParameterGroups in AWS SDK for Ruby API Reference.
-
For a complete list of AWS SDK developer guides and code examples, see Using this service with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.