这是What is the correct syntax for filtering by tag in describe-vpcs?的后续问题 .
使用提供的答案并参考http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-security-groups.html
--filters (list)
One or more filters.
......
vpc-id - The ID of the VPC specified when the security group was created.
我构建了cli请求
aws --profile myProfile --region eu-west-1 ec2 describe-security-groups --group-name MyVpcSecGroup --filters Name=tag:vpc-id,Values=vpc-9xxxxxxx
但是我收到了一个错误
默认VPC“vpc-bxxxxxx”中不存在安全组“MyVpcSecGroup”
那么如何使用-filters列表(如vpc-id)格式化语法以在非默认VPC中搜索安全组?
thx艺术
2 回答
以下是我们在寻找特定群体时如何做到这一点:
文件说:
因此,似乎
--group-names
不能用于非默认VPC .但是,还有其他方法:
要根据特定的 VPC and Name 过滤:
要根据特定的 VPC and any Tag 过滤:
要根据特定的 VPC and a specific Tag 过滤:
注意:标记名称和值为 case-sensitive .