纠正AWS CLI语法找到找到一个VPC安全组在非默认VPC [英] correct aws cli syntax to find find a VPC security group in a non default VPC

查看:686
本文介绍了纠正AWS CLI语法找到找到一个VPC安全组在非默认VPC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是从<一个问题后续href="http://stackoverflow.com/questions/27057932/what-is-the-correct-syntax-for-filtering-by-tag-in-describe-vpcs">What在描述-VPCS的正确语法筛选按标签?。

使用所提供的答案和参考 HTTP: //docs.aws.amazon.com/cli/latest/reference/ec2/describe-security-groups.html

Using the answer provided and referencing 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的请求

I have constructed the cli request

aws --profile myProfile --region eu-west-1 ec2 describe-security-groups --group-name MyVpcSecGroup --filters Name=tag:vpc-id,Values=vpc-9xxxxxxx

不过,我得到一个错误

however I get an error

安全组MyVpcSecGroup在默认情况下不存在VPC   'VPC-bxxxxxx

The security group 'MyVpcSecGroup' does not exist in default VPC 'vpc-bxxxxxx'

那么,如何格式化用--filters如VPC-ID的列表来搜索安全组在非默认VPC语法?

So how do I format the syntax to search for a security group in a non default VPC using a list of --filters such as vpc-id?

THX艺术

推荐答案

该文件说:

   --group-names (list)
      [EC2-Classic, default VPC] One or more security group names.

因此​​,它似乎是 - 组名不能在非默认VPC使用

So, it would seem that --group-names cannot be used on a non-default VPC.

但是,也有替代方法:

aws ec2 describe-security-groups --group-ids sg-xxxxxxxx
aws ec2 describe-security-groups --filters Name=group-name,Values=MyVpcSecGroup

要基于特定的 VPC和名称过滤器:

aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=group-name,Values=MyVpcSecGroup

要筛选基于一个特定的 VPC以及任何标签

To filter based on a specific VPC and any Tag:

aws ec2 describe-security-groups --filters Name=vpc-id,Values=vpc-11223344 Name=tag-value,Values=Production

要筛选基于一个特定的 VPC和一个特定的标签

To filter based on a specific VPC and a specific Tag:

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

请注意:标签名称和值是区分大小写

Note: Tag names and values are case-sensitive.

这篇关于纠正AWS CLI语法找到找到一个VPC安全组在非默认VPC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆