aws的过滤器语法rds describe-db-instances

时间:2017-09-05 09:28:15

标签: amazon-web-services amazon-rds aws-cli

当我们使用过滤器运行命令时,我们收到错误:

C:\Program Files\Amazon\AWSCLI>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.

使用aws rds describe-db-instances过滤器的正确语法是什么?

1 个答案:

答案 0 :(得分:5)

您的语法似乎没问题,但instance-state-name根本不是RDS的有效过滤器。

来自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.

由于RDS不存在instance-state-name之类的内容,因此我假设您正在搜索的内容为DBInstanceStatus。虽然无法使用--filter进行过滤,但您可以使用--query

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

--filter--query之间的区别在于--filter直接影响API发回的内容,而--query对结果进行了一些本地过滤从API收到。只要您没有大量的RDS实例,--query就可以正常使用。