我一直在阅读https://docs.aws.amazon.com/cli/v1/userguide/cli-usage-filter.html和https://jmespath.org/specification.html上的文档,但它不起作用。
例如,我想使用 starts_with 来查找 DBInstances.DBInstanceIdentifier 以“foo”开头的数据库实例。
aws rds describe-db-instances --query 'DBInstances.DBInstanceIdentifier[?starts_with(@, "foo")]'
null
---
aws rds describe-db-instances --query 'DBInstances[?starts_with("DBInstanceIdentifier", "foo")]'
In function starts_with(), invalid type for value: None, expected one of: ['string'], received: "null"
---
aws rds describe-db-instances --query 'DBInstances[?starts_with(DBInstanceIdentifier, "foo")]'
In function starts_with(), invalid type for value: None, expected one of: ['string'], received: "null"
我还想使用诸如 contains 等函数来做其他事情,但这些函数似乎都不起作用。
我知道我可以通过 jq 传递输出,这是一个简单的解决方案,只是想了解更多工具
aws rds describe-db-instances | jq '.DBInstances[] | select(.DBInstanceIdentifier | startswith("foo"))'