authorizeSecurityGroupEgress

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.

If you want to reference a security group across VPCs attached to a transit gateway using the security group referencing feature, note that you can only reference security groups for ingress rules. You cannot reference a security group for egress rules.

Samples

import aws.sdk.kotlin.services.ec2.model.IpPermission
import aws.sdk.kotlin.services.ec2.model.IpRange
import aws.sdk.kotlin.services.ec2.model.UserIdGroupPair
fun main() { 
   //sampleStart 
   // This example adds a rule that grants access to the specified address ranges on TCP port 80.
val resp = ec2Client.authorizeSecurityGroupEgress {
    groupId = "sg-1a2b3c4d"
    ipPermissions = listOf<IpPermission>(
        IpPermission {
            ipProtocol = "tcp"
            fromPort = 80
            toPort = 80
            ipRanges = listOf<IpRange>(
                IpRange {
                    cidrIp = "10.0.0.0/16"
                }                    
            )
        }            
    )
} 
   //sampleEnd
}
import aws.sdk.kotlin.services.ec2.model.IpPermission
import aws.sdk.kotlin.services.ec2.model.IpRange
import aws.sdk.kotlin.services.ec2.model.UserIdGroupPair
fun main() { 
   //sampleStart 
   // This example adds a rule that grants access to the specified security group on TCP port 80.
val resp = ec2Client.authorizeSecurityGroupEgress {
    groupId = "sg-1a2b3c4d"
    ipPermissions = listOf<IpPermission>(
        IpPermission {
            ipProtocol = "tcp"
            fromPort = 80
            toPort = 80
            userIdGroupPairs = listOf<UserIdGroupPair>(
                UserIdGroupPair {
                    groupId = "sg-4b51a32f"
                }                    
            )
        }            
    )
} 
   //sampleEnd
}