AuthorizeSecurityGroupEgress
[VPC only] Adds the specified outbound (egress) rules to a security group for use with a VPC.
An outbound rule permits instances to send traffic to the specified IPv4 or IPv6 CIDR
address ranges, or to the instances that are associated with the specified source
security groups. When specifying an outbound rule for your security group in a VPC, the
IpPermissions
must include a destination for the traffic.
You specify a protocol for each rule (for example, TCP). For the TCP and UDP protocols, you must also specify the destination port or port range. For the ICMP protocol, 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.
Rule changes are propagated to affected instances as quickly as possible. However, a small delay might occur.
For information about VPC security group quotas, see Amazon VPC quotas.
Request Parameters
The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.
- CidrIp
-
Not supported. Use a set of IP permissions to specify the CIDR.
Type: String
Required: No
- DryRun
-
Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is
DryRunOperation
. Otherwise, it isUnauthorizedOperation
.Type: Boolean
Required: No
- FromPort
-
Not supported. Use a set of IP permissions to specify the port.
Type: Integer
Required: No
- GroupId
-
The ID of the security group.
Type: String
Required: Yes
- IpPermissions.N
-
The sets of IP permissions. You can't specify a destination security group and a CIDR IP address range in the same set of permissions.
Type: Array of IpPermission objects
Required: No
- IpProtocol
-
Not supported. Use a set of IP permissions to specify the protocol name or number.
Type: String
Required: No
- SourceSecurityGroupName
-
Not supported. Use a set of IP permissions to specify a destination security group.
Type: String
Required: No
- SourceSecurityGroupOwnerId
-
Not supported. Use a set of IP permissions to specify a destination security group.
Type: String
Required: No
- TagSpecification.N
-
The tags applied to the security group rule.
Type: Array of TagSpecification objects
Required: No
- ToPort
-
Not supported. Use a set of IP permissions to specify the port.
Type: Integer
Required: No
Response Elements
The following elements are returned by the service.
- requestId
-
The ID of the request.
Type: String
- return
-
Returns
true
if the request succeeds; otherwise, returns an error.Type: Boolean
- securityGroupRuleSet
-
Information about the outbound (egress) security group rules that were added.
Type: Array of SecurityGroupRule objects
Errors
For information about the errors that are common to all actions, see Common client error codes.
Examples
Example 1
This example request grants your security group with the ID
sg-1a2b3c4d
access to the 192.0.2.0/24
and
198.51.100.0/24
IPv4 address ranges on TCP port 80.
Sample Request
https://ec2.amazonaws.com/?Action=AuthorizeSecurityGroupEgress
&GroupId=sg-1a2b3c4d
&IpPermissions.1.IpProtocol=tcp
&IpPermissions.1.FromPort=80
&IpPermissions.1.ToPort=80
&IpPermissions.1.IpRanges.1.CidrIp=192.0.2.0/24
&IpPermissions.1.IpRanges.2.CidrIp=198.51.100.0/24
&AUTHPARAMS
Sample Response
<AuthorizeSecurityGroupEgressResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<return>true</return>
</AuthorizeSecurityGroupEgressResponse>
Example 2
This example request grants egress access from the security group with the ID sg-1a2b3c4d
to the security group with the ID sg-9a8d7f5c
on TCP port 1433.
Sample Request
https://ec2.amazonaws.com/?Action=AuthorizeSecurityGroupEgress
&GroupId=sg-1a2b3c4d
&IpPermissions.1.IpProtocol=tcp
&IpPermissions.1.FromPort=1433
&IpPermissions.1.ToPort=1433
&IpPermissions.1.Groups.1.GroupId=sg-9a8d7f5c
&AUTHPARAMS
Example 3
This example request grants your security group with the ID
sg-1a2b3c4d
access to the 2001:db8:1234:1a00::/64
IPv6 address
range on TCP port 22.
Sample Request
https://ec2.amazonaws.com/?Action=AuthorizeSecurityGroupEgress
&GroupId=sg-1a2b3c4d
&IpPermissions.1.IpProtocol=tcp
&IpPermissions.1.FromPort=22
&IpPermissions.1.ToPort=22
&IpPermissions.1.Ipv6Ranges.1.CidrIpv6=2001:db8:1234:1a00::/64
&AUTHPARAMS
Example 4
This example grants access over port 3389 (RDP) to the 192.0.2.0/24
IPv4 address range, and includes a description for the rule to help you identify the rule
later.
Sample Request
https://ec2.amazonaws.com/?Action=AuthorizeSecurityGroupEgress
&GroupId=sg-112233
&IpPermissions.1.IpProtocol=tcp
&IpPermissions.1.FromPort=3389
&IpPermissions.1.ToPort=3389
&IpPermissions.1.IpRanges.1.CidrIp=192.0.2.0/24
&IpPermissions.1.IpRanges.1.Description=Access to London office
See Also
For more information about using this API in one of the language-specific Amazon SDKs, see the following: