AWS CLI按标签搜索资源 [英] AWS CLI search resource by tags
问题描述
我正在尝试使用AWS CLI通过标签搜索资源.
I am trying to use AWS CLI to search for resources by tags.
我准备这个tag.json
文件:
{ "TagFilters":[{ "Value":"postgres-dev", 键":名称" } ] }
{ "TagFilters": [ { "Value": "postgres-dev", "Key": "Name" } ] }
并使用以下命令:
aws resourcegroupstaggingapi get-resources --tag-filters --cli-input-json文件://tag.json
aws resourcegroupstaggingapi get-resources --tag-filters --cli-input-json file://tag.json
但是,它不仅返回具有此标签的数据库,还返回我的AWS账户(EC2,ELB等)中的每个资源
However, instead of returning only the databases which have this tag, it returns every resource in my AWS account (EC2, ELB, etc.)
有人可以告诉我我在哪里做错了吗?
Can anyone show me where did I do wrong?
非常感谢.
推荐答案
可以用纯文本语法代替JSON尝试吗?
Can you try it in plain text syntax in place of JSON?
aws resourcegroupstaggingapi get-resources --tag-filters "Key=Name,Values=postgres-dev"
此外,我认为应该是值",而不是值".
Also, I think should be "Values", not "Value".
让我知道;)
使用JSON语法更新:
Update with JSON syntax:
aws resourcegroupstaggingapi get-resources --cli-input-json file://tag.json
JSON正文:
{ "TagFilters": [ { "Key": "Name", "Values": [ "postgres-dev" ] } ] }
这篇关于AWS CLI按标签搜索资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!