| Did this page help you? Yes No Tell us about it... |
This command applies to both EC2 security groups and VPC security groups. For information about VPC security groups and how they differ from EC2 security groups, go to the Security Groups in the Amazon Virtual Private Cloud User Guide.
This command removes a rule from a security group. The rule can be for ingress traffic, or for egress traffic (only if this is a VPC security group).
The values that you specify in the revoke request (e.g., ports, etc.) must match the existing rule's values in order for the rule to be removed.
Each rule consists of the protocol (e.g., TCP), plus either a CIDR range, or a source group (for ingress rules) or destination group (for egress rules). For TCP and UDP, you must also specify the destination port or port ranges. You can specify -1 to mean all ports (i.e., port range 0-65535). For ICMP, you must also specify the ICMP type and code. You can use -1 for the type or code to mean all types or all codes.
Permission changes are propagated to instances within the security group as quickly as possible. However, a small delay might occur.
The short version of this command is ec2revoke.
ec2-revoke
group [--egress] [-P protocol] (-p port_range |
-t icmp_type_code) [-u source_or_dest_group_owner ...] [-o
source_or_dest_group ...] [-s source_or_dest_cidr ...]
| Name | Description | Required |
|---|---|---|
|
|
For EC2 groups: Name or ID of the security group to modify. For VPC groups: ID of the security group to modify (e.g., sg-1a2b3c4d). The group must belong to your AWS account. Type: String Default: None Example: websrv |
Yes |
--egress
|
Optional flag applicable only to VPC security groups. The flag designates the rule is an egress rule (i.e., controls traffic leaving the VPC security group). Default: If this is not specified, the rule applies to ingress traffic for the specified security group | No |
|
|
IP protocol name or number to revoke (go to Protocol Numbers). EC2 security groups can have rules only for TCP, UDP, and ICMP, whereas VPC security groups can have rules assigned to any protocol number. When you call Type: String Valid Values for EC2 security groups: Default for EC2 groups: Defaults to TCP if source CIDR is specified (or implied by default), or all three protocols (TCP, UDP, and ICMP) if source group is specified (to ensure backwards compatibility). Valid Values for VPC groups: Condition: Required for VPC security groups. Example: -P udp |
Conditional |
|
|
For TCP or UDP, this specifies the range of ports to revoke. Type: String Default: None Valid Values: A single integer or a range (min-max). You can specify -1 to mean all ports (i.e., port range 0-65535). Condition: Required if specifying Example: -p 80-84 |
Conditional |
|
|
For ICMP, this specifies the ICMP type and code to revoke. This must be specified in the format type:code where both are integers. You can use -1 for the type or code to mean all types or all codes. Type: String Default: None Condition: Required if specifying Example: -t -1:-1 |
Conditional |
|
|
AWS account ID that owns the source security group (for ingress rules) or destination security group (for egress rules). If the group is in your own account, set this to your own AWS account ID. Cannot be used when specifying a CIDR IP address. Type: String Default: None Condition: Required when revoking a rule that gives access to one or more source security groups. Example: -u 999988887777 |
Conditional |
|
|
The source security group (for ingress rules), or destination security group (for egress rules). When revoking a rule for a VPC security group, you must specify the group's ID (e.g., sg-9d4e5f6g) instead of its name. Cannot be used when specifying a CIDR IP address with the -s option. Type: String Default: None Condition: Required if revoking access to one or more source or destination security groups. Example: -o headoffice |
Conditional |
|
|
CIDR range. Cannot be used when specifying a source or destination security group with the -o option. Type: String Default: 0.0.0.0/0 Constraints: Valid CIDR IP address range. Condition: Required if revoking access to one or more IP address ranges. Example: -s 205.192.8.45/24 |
Conditional |
| Option | Description |
|---|---|
|
|
Overrides the Region specified in the Default: The Example: |
|
|
Default: The Example: |
|
|
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: |
|
|
Specifies a connection timeout (in seconds). Example: --connection-timeout 30 |
|
|
Specifies a request timeout (in seconds). Example: --request-timeout 45 |
|
|
Displays verbose output by showing the SOAP request and response on the command line. This is particularly useful if you are building tools to talk directly to our SOAP API. |
|
|
Displays column headers in the output. |
|
|
Shows empty columns as |
|
|
Do not display tags for tagged resources. |
|
|
Prints internal debugging information. This is useful to assist us when troubleshooting problems. |
|
|
Displays Help. |
|
|
If Example: |
The command returns a table that contains the following information:
Output type identifier ("GROUP", "PERMISSION")
Group name; currently, this will report an empty string
Type of rule; currently, only ALLOW rules are supported
Protocol to allow
Start of port range
End of port range
FROM
Source
Amazon EC2 command line tools display errors on stderr.
This example revokes TCP port 80 access from the 205.192.0.0/16 address range for the websrv security group.
PROMPT>ec2-revoke websrv -P tcp -p 80 -s 205.192.0.0/16GROUP websrv PERMISSION websrv ALLOWS tcp 80 80 FROM CIDR 205.192.0.0/16