当我们使用过滤器运行命令时,我们收到错误:
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
过滤器的正确语法是什么?
答案 0 :(得分:5)
您的语法似乎没问题,但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
就可以正常使用。