AWS CLI search resource by tags

自古美人都是妖i 提交于 2019-12-11 08:03:47

问题


I am trying to use AWS CLI to search for resources by tags.

I prepare this tag.json file:

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

and use this command:

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

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?

Thanks a lot.


回答1:


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".

Let me know ;)

Update with JSON syntax:

aws resourcegroupstaggingapi get-resources --cli-input-json file://tag.json

JSON body:

{ "TagFilters": [ { "Key": "Name", "Values": [ "postgres-dev" ] } ] }


来源:https://stackoverflow.com/questions/52594359/aws-cli-search-resource-by-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!