Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to describe Security Groups for a VPC?

Is there a way to describe a Security Group in a specific VPC?

Here is what I am trying to run :

aws ec2 describe-security-groups --group-name "<group-name>" --filter Name=vpc-id,Values=<my-vpc-id>

But it is returning this error :

A client error (VPCIdNotSpecified) occurred when calling the DescribeSecurityGroups operation: No default VPC for this user

I appreciate your help,

Thanks

like image 586
Arun Avanathan Avatar asked Nov 02 '16 05:11

Arun Avanathan


People also ask

What are security groups in VPC?

A security group is like a virtual firewall. It works much like a traditional firewall does. It consists of a set of rules that can be used to monitor and filter an instance's incoming and outgoing traffic in a Virtual Private Cloud (VPC) instance. Filtering is done on the basis of protocols and ports.

What best describes a security group?

Which statement best describes security groups? They are stateful and deny all inbound traffic by default.

Can you specify the security group that you created for a VPC?

When you launch an instance in a VPC, you must specify a security group that's created for that VPC. After you launch an instance, you can change its security groups. Security groups are associated with network interfaces.


1 Answers

To describe all security groups in a given VPC:

aws ec2 describe-security-groups --filters "Name=vpc-id,Values=vpc-abcd1234"

To describe a specific security group by its ID:

aws ec2 describe-security-groups --group-id sg-1234abcd

To describe a specific security group by its name (for non-default VPCs):

aws ec2 describe-security-groups --filters Name=group-name,Values=MY-SG

To describe a specific security group by its name and VPC (since there can be multiple groups with the same name in different VPCS):

aws ec2 describe-security-groups --filters Name=group-name,Values=MY-SG Name=vpc-id,Values=vpc-abcd1234

See AWS Command-Line Interface (CLI) documentation: describe-security-groups

like image 115
John Rotenstein Avatar answered Oct 22 '22 07:10

John Rotenstein