Difference between revisions of "Aws ec2 describe-security-groups"
Jump to navigation
Jump to search
(9 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
* https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-security-groups.html | * https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-security-groups.html | ||
− | + | ||
− | aws ec2 describe-security-groups | grep Description | + | aws ec2 describe-security-groups | grep [[Description]] |
− | [[aws ec2]] describe-security-groups | egrep "GroupId|Description" | + | [[aws ec2]] describe-security-groups | egrep "[[GroupId]]|[[Description]]" |
aws ec2 describe-security-groups --group-ids sg-0cc21460XXXXX | aws ec2 describe-security-groups --group-ids sg-0cc21460XXXXX | ||
+ | |||
+ | Describe security group with specific rule: | ||
+ | aws ec2 describe-security-groups \ | ||
+ | --filters Name=ip-permission.from-port,Values=22 Name=ip-permission.to-port,Values=22 Name=ip-permission.cidr,Values='0.0.0.0/0' \ | ||
+ | --query "SecurityGroups[*].[GroupName]" \ | ||
+ | --output text | ||
+ | |||
+ | == Official example == | ||
+ | aws ec2 describe-security-groups --group-ids sg-903004f8 | ||
+ | <pre> | ||
+ | { | ||
+ | "SecurityGroups": [ | ||
+ | { | ||
+ | "IpPermissionsEgress": [ | ||
+ | { | ||
+ | "IpProtocol": "-1", | ||
+ | "IpRanges": [ | ||
+ | { | ||
+ | "CidrIp": "0.0.0.0/0" | ||
+ | } | ||
+ | ], | ||
+ | "UserIdGroupPairs": [], | ||
+ | "PrefixListIds": [] | ||
+ | } | ||
+ | ], | ||
+ | "Description": "My security group", | ||
+ | "Tags": [ | ||
+ | { | ||
+ | "Value": "SG1", | ||
+ | "Key": "Name" | ||
+ | } | ||
+ | ], | ||
+ | "IpPermissions": [ | ||
+ | { | ||
+ | "IpProtocol": "-1", | ||
+ | "IpRanges": [], | ||
+ | "UserIdGroupPairs": [ | ||
+ | { | ||
+ | "UserId": "123456789012", | ||
+ | "GroupId": "sg-903004f8" | ||
+ | } | ||
+ | ], | ||
+ | "PrefixListIds": [] | ||
+ | }, | ||
+ | { | ||
+ | "PrefixListIds": [], | ||
+ | "FromPort": 22, | ||
+ | "IpRanges": [ | ||
+ | { | ||
+ | "Description": "Access from NY office", | ||
+ | "CidrIp": "203.0.113.0/24" | ||
+ | } | ||
+ | ], | ||
+ | "ToPort": 22, | ||
+ | "IpProtocol": "tcp", | ||
+ | "UserIdGroupPairs": [] | ||
+ | } | ||
+ | ], | ||
+ | "GroupName": "MySecurityGroup", | ||
+ | "VpcId": "vpc-1a2b3c4d", | ||
+ | "OwnerId": "123456789012", | ||
+ | "GroupId": "sg-903004f8", | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | </pre> | ||
== Related == | == Related == | ||
* <code>aws ec2</code> | * <code>aws ec2</code> | ||
+ | * <code>[[aws ec2 create-security-group]]</code> | ||
+ | * <code>[[aws rds describe-db-security-groups]]</code> | ||
+ | * <code>[[aws ec2 describe-vpcs]]</code> | ||
+ | * <code>[[kubernetes.io/rule/]]</code> | ||
== See also == | == See also == |
Latest revision as of 13:51, 26 October 2023
- https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-security-groups.html
aws ec2 describe-security-groups | grep Description aws ec2 describe-security-groups | egrep "GroupId|Description" aws ec2 describe-security-groups --group-ids sg-0cc21460XXXXX
Describe security group with specific rule:
aws ec2 describe-security-groups \ --filters Name=ip-permission.from-port,Values=22 Name=ip-permission.to-port,Values=22 Name=ip-permission.cidr,Values='0.0.0.0/0' \ --query "SecurityGroups[*].[GroupName]" \ --output text
Official example[edit]
aws ec2 describe-security-groups --group-ids sg-903004f8
{ "SecurityGroups": [ { "IpPermissionsEgress": [ { "IpProtocol": "-1", "IpRanges": [ { "CidrIp": "0.0.0.0/0" } ], "UserIdGroupPairs": [], "PrefixListIds": [] } ], "Description": "My security group", "Tags": [ { "Value": "SG1", "Key": "Name" } ], "IpPermissions": [ { "IpProtocol": "-1", "IpRanges": [], "UserIdGroupPairs": [ { "UserId": "123456789012", "GroupId": "sg-903004f8" } ], "PrefixListIds": [] }, { "PrefixListIds": [], "FromPort": 22, "IpRanges": [ { "Description": "Access from NY office", "CidrIp": "203.0.113.0/24" } ], "ToPort": 22, "IpProtocol": "tcp", "UserIdGroupPairs": [] } ], "GroupName": "MySecurityGroup", "VpcId": "vpc-1a2b3c4d", "OwnerId": "123456789012", "GroupId": "sg-903004f8", } ] }
Related[edit]
aws ec2
aws ec2 create-security-group
aws rds describe-db-security-groups
aws ec2 describe-vpcs
kubernetes.io/rule/
See also[edit]
- AWS Security group (SG):
aws ec2 [ create-security-group | describe-security-groups | delete-security-group | authorize-security-group-ingress | authorize-security-group-egress ]
- AWS EC2, AWS::EC2,
aws ec2
[describe-instances | describe-instance-status
|run-instances | terminate-instances | stop-instances
|tags
|describe-vpcs
|describe-addresses
|describe-availability-zones
|describe-subnets
|import-key-pair
|create-key-pair
|create-vpc
|create-internet-gateway
|modify-instance-attribute | ec2-instance-connect | get-console-output
]
Advertising: