| « PreviousNext » | |
![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
Describes one or more of your security groups.
A security group is for use with instances either in the EC2-Classic platform or in a specific VPC. For more information, see Amazon EC2 Security Groups in the Amazon Elastic Compute Cloud User Guide and Security Groups for Your VPC in the Amazon Virtual Private Cloud User Guide.
The short version of this command is ec2dgrp.
ec2-describe-group
[
ec2_group_name_or_id |
vpc_group_id ...]
[[--filter "name=value"] ...]
| Name | Description |
|---|---|
|
|
EC2-Classic, default VPC: The name or ID of one or more security groups. nondefault VPC: The ID of one more security groups. Type: String Default: Describes all your security groups, or only those you specified by name. Required: No Example: websrv |
|
|
A filter for limiting the results. See the Supported Filters section for a list of supported filters. Use quotation marks if the value string has a space ("name=value example"). On a Windows system, use quotation marks even without a space in the value string ("name=value"). Type: String Default: Describes all your security groups, or only those you specified by ID. Required: No Example: --filter "group-name=*webserver*" |
You can specify filters so that the response includes information for only certain security groups. For example, you can use a filter to specify that you're interested in groups whose name contains a specific string. You can specify multiple values for a filter. The response includes information for a security group only if it matches at least one of the filter values that you specified.
You can specify multiple filters; for example, specify group's whose name contains a specific string, and that give permission to another security group with a different string in its name. The response includes information for a group only if it matches all the filters that you specified. If there's no match, no special message is returned, the response is simply empty.
Important
Filters are based on literal strings only. This is important to remember when you want to use filters to return only security groups with access allowed on a specific port number or numbers. For example, suppose that you want to get all groups that have access on port 22, and that GroupA gives access on a range of ports using fromPort=20 and toPort=30. If you filter with ip-permission.from-port=22 or ip-permission.to-port=22 (or both), the response does not contain information for GroupA. You get information for GroupA only if you specify ip-permission.from-port=20 or ip-permission.to-port=30 (or both).
You can use wildcards in a filter value. An asterisk (*) matches zero or more characters, and a question mark (?) matches exactly one character. You can escape special characters using a backslash (\) before the character. For example, a value of \*amazon\?\\ searches for the literal string *amazon?\.
The following are the available filters.
descriptionThe description of the security group.
Type: String
group-idThe ID of the security group.
Type: String
group-nameThe name of the security group.
Type: String
ip-permission.cidrThe CIDR range that has been granted the permission.
Type: String
ip-permission.from-portThe start of port range for the TCP and UDP protocols, or an ICMP type number.
Type: String
ip-permission.group-nameThe name of security group that has been granted the permission.
Type: String
ip-permission.protocolThe IP protocol for the permission.
Type: String
Valid values: tcp | udp | icmp or a protocol number
ip-permission.to-portThe end of port range for the TCP and UDP protocols, or an ICMP code.
Type: String
ip-permission.user-idThe ID of an AWS account that has been granted the permission.
Type: String
owner-idThe AWS account ID of the owner of the security group.
Type: String
tag-keyThe key of a tag assigned to the security group.
Type: String
tag-valueThe value of a tag assigned to the security group.
Type: String
vpc-idOnly return the security groups that belong to the specified EC2-VPC ID.
Type: String
| Option | Description |
|---|---|
|
|
Overrides the region specified by the Default: The value of the Example: |
|
|
The uniform resource locator (URL) of the Amazon EC2 web service entry point. Default: The value of the Example: |
|
|
The private key that identifies you to Amazon EC2. For more information, see Tell the Tools Who You Are. Default: The value of the Example: |
|
|
The X.509 certificate that identifies you to Amazon EC2. Default: The value of the Example: |
|
|
The access key ID associated with your AWS account. For more information, see Tell the Tools Who You Are. Default: The value of the Example: Note For more information, see the following section, Deprecated Options. |
|
|
The secret access key associated with your AWS account. Default: The value of the Example: Note For more information, see the following section, Deprecated Options. |
|
|
The AWS delegation token. Default: The value of the environment variable (if set). |
|
|
The connection timeout, in seconds. Example: |
|
|
The request timeout, in seconds. Example: |
|
|
Displays verbose output, including the API request and response on the command line. This is useful if you are building tools to talk directly to our Query API. |
|
|
Includes column headers in the command output. |
|
|
Shows empty columns as |
|
|
Omits tags for tagged resources. |
|
|
Displays internal debugging information. This can assist us when helping you troubleshooting problems. |
|
|
Displays usage information for the command. |
|
|
Reads arguments from standard input. This is useful when piping the output from one command to the input of another. Example: |
For a limited time, you can still use the private key and X.509 certificate instead of your access key ID and secret access key. However, we recommend that you start using your access key ID (-O, --aws-access-key) and secret access key (-W, --aws-secret-key) now, as the private key (-K, --private-key) and X.509 certificate (-C, --cert) won't be supported after the transition period elapses. For more information, see Tell the Tools Who You Are.
| Option | Description |
|---|---|
|
|
The private key to use when constructing requests to Amazon EC2. Default: The value of the Example: |
|
|
The X.509 certificate to use when constructing requests to Amazon EC2. Default: The value of the Example: |
This command returns a table that contains the following information:
A line containing the group information
The GROUP identifier
The ID of the security group
The AWS account ID of the owner of the security group
The name of the security group
A description of the security group
[VPC only] The ID of the VPC the group belongs to
One of each of the following lines for each permission defined by the group:
The PERMISSION identifier
The AWS account ID of the owner of the group
The name of the group granting permission
The type of rule. Currently, only ALLOWS rules are supported
The protocol to allow (e.g. tcp, udp, etc)
The start of port range
The end of port range
FROM for an ingress rule or TO for an egress rule
The source type (for ingress rules) or destination type (for egress rules)
The source (for ingress rules) or destination (for egress rules)
[USER only] The name of the source or destination entity
[USER only] The group ID
Whether the rule is ingress rule or an egress rule
Amazon EC2 command line tools display errors on stderr.
This example returns information about a security group for EC2-Classic named
StandardGroup.
PROMPT>ec2-describe-group StandardGroupGROUP sg-1a2b3c4d 111122223333 StandardGroup A standard EC2 group PERMISSION 111122223333 StandardGroup ALLOWS tcp 80 80 FROM CIDR 102.11.43.32/32 ingress
This example returns information about a security group for EC2-VPC with the
ID sg-1a2b3c4d.
PROMPT>ec2-describe-group sg-1a2b3c4dGROUP sg-1a2b3c4d 111122223333 WebServerSG web servers vpc-1a2b3c4d PERMISSION 111122223333 WebServerSG ALLOWS tcp 80 80 FROM CIDR 162.5.5.5/32 ingress PERMISSION 111122223333 WebServerSG ALLOWS tcp 80 80 FROM USER 111122223333 NAME default ID sg-1a2b3c4d ingress PERMISSION 111122223333 WebServerSG ALLOWS tcp 443 443 FROM USER 111122223333 NAME default ID sg-1a2b3c4d ingress PERMISSION 111122223333 WebServerSG ALLOWS all TO CIDR 0.0.0.0/0 egress PERMISSION 111122223333 WebServerSG ALLOWS tcp 433 433 TO USER 111122223333 NAME default ID sg-1a2b3c4d egress
This example returns information about all security groups that grant access over TCP specifically on port 22 from instances in either the app_server_group or database_group.
PROMPT> ec2-describe-group --filter "ip-permission.protocol=tcp"
--filter "ip-permission.from-port=22" --filter "ip-permission.to-port=22"
--filter "ip-permission.group-name=app_server_group" --filter "ip-permission.group-name=database_group"