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

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

问题描述

这是来自使用提供的答案并引用 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

但是我遇到错误

默认VPC中不存在安全组"MyVpcSecGroup" '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 Art

推荐答案

文档说:

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

因此,似乎--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和名称进行过滤:

To filter based on a specific VPC and Name:

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

注意:标记名称和值区分大小写.

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

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