Class: AWSCDK::EC2::CfnSecurityGroup::EgressProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
ec2/cfn_security_group.rb

Overview

Adds the specified outbound (egress) rule to a security group.

An outbound rule permits instances to send traffic to the specified IPv4 or IPv6 address range, the IP address ranges that are specified by a prefix list, or the instances that are associated with a destination security group. For more information, see Security group rules .

You must specify exactly one of the following destinations: an IPv4 address range, an IPv6 address range, a prefix list, or a security group.

You must specify a protocol for each rule (for example, TCP). If the protocol is TCP or UDP, you must also specify a port or port range. If the protocol is ICMP or ICMPv6, you must also specify the ICMP/ICMPv6 type and code.

Rule changes are propagated to instances associated with the security group as quickly as possible. However, a small delay might occur.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip_protocol:, cidr_ip: nil, cidr_ipv6: nil, description: nil, destination_prefix_list_id: nil, destination_security_group_id: nil, from_port: nil, to_port: nil) ⇒ EgressProperty

Returns a new instance of EgressProperty.

Parameters:

  • ip_protocol (String)

    The IP protocol name ( tcp , udp , icmp , icmpv6 ) or number (see Protocol Numbers ).

  • cidr_ip (String, nil) (defaults to: nil)

    The IPv4 address range, in CIDR format.

  • cidr_ipv6 (String, nil) (defaults to: nil)

    The IPv6 address range, in CIDR format.

  • description (String, nil) (defaults to: nil)

    A description for the security group rule.

  • destination_prefix_list_id (String, nil) (defaults to: nil)

    The prefix list IDs for the destination AWS service.

  • destination_security_group_id (String, nil) (defaults to: nil)

    The ID of the destination VPC security group.

  • from_port (Numeric, nil) (defaults to: nil)

    If the protocol is TCP or UDP, this is the start of the port range.

  • to_port (Numeric, nil) (defaults to: nil)

    If the protocol is TCP or UDP, this is the end of the port range.



638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
# File 'ec2/cfn_security_group.rb', line 638

def initialize(ip_protocol:, cidr_ip: nil, cidr_ipv6: nil, description: nil, destination_prefix_list_id: nil, destination_security_group_id: nil, from_port: nil, to_port: nil)
  @ip_protocol = ip_protocol
  Jsii::Type.check_type(@ip_protocol, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "ipProtocol")
  @cidr_ip = cidr_ip
  Jsii::Type.check_type(@cidr_ip, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "cidrIp") unless @cidr_ip.nil?
  @cidr_ipv6 = cidr_ipv6
  Jsii::Type.check_type(@cidr_ipv6, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "cidrIpv6") unless @cidr_ipv6.nil?
  @description = description
  Jsii::Type.check_type(@description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description") unless @description.nil?
  @destination_prefix_list_id = destination_prefix_list_id
  Jsii::Type.check_type(@destination_prefix_list_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "destinationPrefixListId") unless @destination_prefix_list_id.nil?
  @destination_security_group_id = destination_security_group_id
  Jsii::Type.check_type(@destination_security_group_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "destinationSecurityGroupId") unless @destination_security_group_id.nil?
  @from_port = from_port
  Jsii::Type.check_type(@from_port, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "fromPort") unless @from_port.nil?
  @to_port = to_port
  Jsii::Type.check_type(@to_port, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "toPort") unless @to_port.nil?
end

Instance Attribute Details

#cidr_ipString? (readonly)

The IPv4 address range, in CIDR format.

You must specify exactly one of the following: CidrIp , CidrIpv6 , DestinationPrefixListId , or DestinationSecurityGroupId .

For examples of rules that you can add to security groups for specific access scenarios, see Security group rules for different use cases in the Amazon EC2 User Guide .



672
673
674
# File 'ec2/cfn_security_group.rb', line 672

def cidr_ip
  @cidr_ip
end

#cidr_ipv6String? (readonly)

The IPv6 address range, in CIDR format.

You must specify exactly one of the following: CidrIp , CidrIpv6 , DestinationPrefixListId , or DestinationSecurityGroupId .

For examples of rules that you can add to security groups for specific access scenarios, see Security group rules for different use cases in the Amazon EC2 User Guide .



681
682
683
# File 'ec2/cfn_security_group.rb', line 681

def cidr_ipv6
  @cidr_ipv6
end

#descriptionString? (readonly)

A description for the security group rule.

Constraints: Up to 255 characters in length. Allowed characters are a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=;{}!$*



688
689
690
# File 'ec2/cfn_security_group.rb', line 688

def description
  @description
end

#destination_prefix_list_idString? (readonly)

The prefix list IDs for the destination AWS service.

This is the AWS service that you want to access through a VPC endpoint from instances associated with the security group.

You must specify exactly one of the following: CidrIp , CidrIpv6 , DestinationPrefixListId , or DestinationSecurityGroupId .



697
698
699
# File 'ec2/cfn_security_group.rb', line 697

def destination_prefix_list_id
  @destination_prefix_list_id
end

#destination_security_group_idString? (readonly)

The ID of the destination VPC security group.

You must specify exactly one of the following: CidrIp , CidrIpv6 , DestinationPrefixListId , or DestinationSecurityGroupId .



704
705
706
# File 'ec2/cfn_security_group.rb', line 704

def destination_security_group_id
  @destination_security_group_id
end

#from_portNumeric? (readonly)

If the protocol is TCP or UDP, this is the start of the port range.

If the protocol is ICMP or ICMPv6, this is the ICMP type or -1 (all ICMP types).



711
712
713
# File 'ec2/cfn_security_group.rb', line 711

def from_port
  @from_port
end

#ip_protocolString (readonly)

The IP protocol name ( tcp , udp , icmp , icmpv6 ) or number (see Protocol Numbers ).

Use -1 to specify all protocols. When authorizing security group rules, specifying -1 or a protocol number other than tcp , udp , icmp , or icmpv6 allows traffic on all ports, regardless of any port range you specify. For tcp , udp , and icmp , you must specify a port range. For icmpv6 , the port range is optional; if you omit the port range, traffic for all types and codes is allowed.



663
664
665
# File 'ec2/cfn_security_group.rb', line 663

def ip_protocol
  @ip_protocol
end

#to_portNumeric? (readonly)

If the protocol is TCP or UDP, this is the end of the port range.

If the protocol is ICMP or ICMPv6, this is the ICMP code or -1 (all ICMP codes). If the start port is -1 (all ICMP types), then the end port must be -1 (all ICMP codes).



718
719
720
# File 'ec2/cfn_security_group.rb', line 718

def to_port
  @to_port
end

Class Method Details

.jsii_propertiesObject



720
721
722
723
724
725
726
727
728
729
730
731
# File 'ec2/cfn_security_group.rb', line 720

def self.jsii_properties
  {
    :ip_protocol => "ipProtocol",
    :cidr_ip => "cidrIp",
    :cidr_ipv6 => "cidrIpv6",
    :description => "description",
    :destination_prefix_list_id => "destinationPrefixListId",
    :destination_security_group_id => "destinationSecurityGroupId",
    :from_port => "fromPort",
    :to_port => "toPort",
  }
end

Instance Method Details

#to_jsiiObject



733
734
735
736
737
738
739
740
741
742
743
744
745
746
# File 'ec2/cfn_security_group.rb', line 733

def to_jsii
  result = {}
  result.merge!({
    "ipProtocol" => @ip_protocol,
    "cidrIp" => @cidr_ip,
    "cidrIpv6" => @cidr_ipv6,
    "description" => @description,
    "destinationPrefixListId" => @destination_prefix_list_id,
    "destinationSecurityGroupId" => @destination_security_group_id,
    "fromPort" => @from_port,
    "toPort" => @to_port,
  })
  result.compact
end