AWS RDS的describe-db-instances过滤器语法

6
当我们使用过滤器运行命令时,出现错误:
$ 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 的过滤器的正确语法是什么?
2个回答

10
你的语法似乎没问题,但是instance-state-name不是RDS的有效筛选器。
文档中可以看到:
--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对您来说应该可以正常工作。


你好,是否有任何方法可以过滤输出字段。.aws rds describe-db-instances --query "DBInstances[?DBInstanceIdentifier==xyz]" --query "DBInstances[*].[DBInstanceArn,Engine,DBInstanceIdentifier,EngineVersion,Address]" - chinta kiran
是的,你也可以使用 --query 选项来实现。请查看文档:http://docs.aws.amazon.com/cli/latest/userguide/controlling-output.html - Dunedan
请仅在一次命令中指定 --query,例如: aws rds describe-db-instances --query "DBInstances[?DBInstanceIdentifier==xyz].[DBInstanceArn,Engine,DBInstanceIdentifier,E‌​ngineVersion,Address‌​]" - Dunedan
有没有办法在以表格格式获取输出时获取头信息。C:\ Program Files \ Amazon \ AWSCLI> aws rds describe-db-instances --query“DBInstances [*]。[Engine,DBInstanceIdentifier,EngineVersion,Endpoint.Address,AllocatedStorage,DBInstanceClass,Endpoint.Port]” - chinta kiran

0

加引号应该可以工作

例子:

aws rds describe-db-cluster-endpoints --db-cluster-identifier=aurora-cluster-dev  --query 'DBClusterEndpoints[*].[Endpoint]' --filters 'Name=db-cluster-endpoint-type,Values=writer'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接