问题
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