Get the list of security groups in the AWS account Prerequisites AWS CLI v2 AWS CLI command to list security groups # filename: list-security-groups aws ec2 describe-security-groups \ --query 'SecurityGroups[*].{ Name:GroupName, Id:GroupId, Vpc:VpcId}' \ --output table Sample output -------------------------------------------------------------- | DescribeSecurityGroups | +-----------------------+----------+-------------------------+ | Id | Name | Vpc | +-----------------------+----------+-------------------------+ | sg-0f18db46b549202de | default | vpc-01e4c55e6e91c5a85 | | sg-13fbac2a | default | vpc-ac2ec5d1 | +-----------------------+----------+-------------------------+ See also List EC2 Instances List Vpcs