AWS CLI按标签搜索资源

tha*_*ang 1 amazon-web-services amazon-rds aws-cli

我正在尝试使用AWS CLI通过标签搜索资源。

我准备这个tag.json文件:

{“ TagFilters”:[{“ Value”:“ postgres-dev”,“ Key”:“ Name”}]}

并使用以下命令:

aws resourcegroupstaggingapi get-resources --tag-filters --cli-input-json文件://tag.json

但是,它不仅返回具有此标签的数据库,还返回我的AWS账户中的每个资源(EC2,ELB等)。

谁能告诉我我在哪里做错了?

非常感谢。

Fra*_*cci 6

您可以用纯文本语法代替JSON尝试吗?

aws resourcegroupstaggingapi get-resources --tag-filters "Key=Name,Values=postgres-dev"
Run Code Online (Sandbox Code Playgroud)

另外,我认为应该是“值”,而不是“值”。

让我知道 ;)

使用JSON语法更新:

aws resourcegroupstaggingapi get-resources --cli-input-json file://tag.json
Run Code Online (Sandbox Code Playgroud)

JSON正文:

{ "TagFilters": [ { "Key": "Name", "Values": [ "postgres-dev" ] } ] }
Run Code Online (Sandbox Code Playgroud)