Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax for filters for aws rds describe-db-instances

When we run the command using filters we are getting the error:

$ aws rds describe-db-instances --filters Name=instance-state-name,Values=running

An error occurred (InvalidParameterValue) when calling the
DescribeDBInstances operation: Unrecognized filter name: instance-state-name.

What is the correct syntax for using filters for aws rds describe-db-instances?

like image 384
chinta kiran Avatar asked Sep 05 '17 09:09

chinta kiran


People also ask

What is DB instance identifier in RDS?

Each DB instance has a DB instance identifier. This customer-supplied name uniquely identifies the DB instance when interacting with the Amazon RDS API and AWS CLI commands. The DB instance identifier must be unique for that customer in an AWS Region.

Which types of Databases instance is available in AWS RDS?

Amazon RDS supports three types of instance classes: general purpose, memory optimized, and burstable performance. For more information about Amazon EC2 instance types, see Instance types in the Amazon EC2 documentation.


1 Answers

Your syntax seems to be fine, but instance-state-name is simply not a valid filter for RDS.

From the documentation:

--filters (list)

A filter that specifies one or more DB instances to describe.

Supported filters:

    db-cluster-id - Accepts DB cluster identifiers and DB cluster Ama-
    zon Resource Names (ARNs). The results list will only include
    information about the DB instances associated with the DB Clusters
    identified by these ARNs.

    db-instance-id - Accepts DB instance identifiers and DB instance
    Amazon Resource Names (ARNs). The results list will only include
    information about the DB instances identified by these ARNs.

As something like instance-state-name doesn't exist for RDS I assume what you're searching for instead is DBInstanceStatus. While it's not possible to use --filter to filter for that, you can use --query:

aws rds describe-db-instances --query 'DBInstances[?DBInstanceStatus==`available`]'

The difference between --filter and --query is that --filter directly influences what's sent back by the API, while --query does some local filtering of the results received from the API. As long as you don't have a very large amount of RDS instances, --query should work fine for you.

like image 129
Dunedan Avatar answered Sep 28 '22 15:09

Dunedan