Amazon web services 更正aws cli语法以在非默认VPC中查找VPC安全组

Amazon web services 更正aws cli语法以在非默认VPC中查找VPC安全组,amazon-web-services,amazon-ec2,amazon-vpc,aws-cli,Amazon Web Services,Amazon Ec2,Amazon Vpc,Aws Cli,这是我们的后续问题 使用提供的答案并参考 我已经构建了cli请求 aws --profile myProfile --region eu-west-1 ec2 describe-security-groups --group-name MyVpcSecGroup --filters Name=tag:vpc-id,Values=vpc-9xxxxxxx 然而,我得到了一个错误 默认VPC中不存在安全组“MyVpcSecGroup” “专有网络bxxxxxx” 那么,如何设置语法格式,以便使用诸

这是我们的后续问题

使用提供的答案并参考

我已经构建了cli请求

aws --profile myProfile --region eu-west-1 ec2 describe-security-groups --group-name MyVpcSecGroup --filters Name=tag:vpc-id,Values=vpc-9xxxxxxx
然而,我得到了一个错误

默认VPC中不存在安全组“MyVpcSecGroup” “专有网络bxxxxxx”

那么,如何设置语法格式,以便使用诸如VPC id之类的过滤器列表在非默认VPC中搜索安全组呢


thx Art

文件中说:

   --group-names (list)
      [EC2-Classic, default VPC] One or more security group names.
因此,
--组名
似乎不能在非默认VPC上使用

但是,也有其他方法:

aws ec2 describe-security-groups --group-ids sg-xxxxxxxx
aws ec2 describe-security-groups --filters Name=group-name,Values=MyVpcSecGroup
要根据特定的专有网络和名称进行过滤

aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=group-name,Values=MyVpcSecGroup
aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=tag-value,Values=Production
aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=tag:Environment,Values=Production
要根据特定的专有网络和任何标签进行过滤

aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=group-name,Values=MyVpcSecGroup
aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=tag-value,Values=Production
aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=tag:Environment,Values=Production
要根据特定的专有网络和特定的标签进行过滤

aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=group-name,Values=MyVpcSecGroup
aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=tag-value,Values=Production
aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=tag:Environment,Values=Production

注意:标记名和值区分大小写,以下是查找特定组时的操作方法:

aws --profile myProfile ec2 describe-security-groups --region=AWS_REGION --filters "Name=vpc-id,Values=VPC_ID" --filters "Name=group-name,Values=NAMEOFSECGROUP"

谢谢@John,我的问题模棱两可,所以我在最后一句话中添加了一些信息。我希望通过基于标记(如vpc-id)进行过滤来获取MyVpcSecGroup信息。该标记应返回特定vpc的特定组id的ifo。Thx Art更新为包含通过Tag.perfect@John进行过滤的示例,添加组名作为过滤器是我所缺少的,Art感谢您的输入,对引号给予+1,因为在某些情况下,如果没有它们,名称会失败,Art