Class: AWS::EC2::SecurityGroup::IpPermission
- Inherits:
-
Object
- Object
- AWS::EC2::SecurityGroup::IpPermission
- Defined in:
- lib/aws/ec2/security_group/ip_permission.rb
Instance Attribute Summary collapse
-
#egress ⇒ Boolean
readonly
True if this is an egress permission.
-
#groups ⇒ Array
readonly
An array of security groups that have been granted access with this permission.
-
#ip_ranges ⇒ Array
readonly
An array of string CIDR ip addresses.
-
#port_range ⇒ Range
readonly
The port range (e.g. 80..80, 4000..4010, etc).
-
#protocol ⇒ Symbol
readonly
The protocol (:tcp, :udp, :icmp).
-
#security_group ⇒ SecurityGroup
readonly
The security group this permission is authorized for.
Instance Method Summary collapse
-
#authorize ⇒ IpPermission
Authorizes this permission from its security group.
-
#egress? ⇒ Boolean
Returns true if this is an egress permission.
-
#eql?(other) ⇒ Boolean
(also: #==)
Returns true if the other IpPermission matches this one.
-
#initialize(security_group, protocol, ports, options = {}) ⇒ IpPermission
constructor
A new instance of IpPermission.
-
#revoke ⇒ IpPermission
Revokes this permission from its security group.
Constructor Details
#initialize(security_group, protocol, ports, options = {}) ⇒ IpPermission
Returns a new instance of IpPermission.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 36 def initialize security_group, protocol, ports, = {} @security_group = security_group @protocol = protocol == '-1' ? :any : protocol.to_s.downcase.to_sym @ip_ranges = Array([:ip_ranges]) @groups = Array([:groups]) @egress = [:egress] || false # not all egress permissions require port ranges, depends on the # protocol if ports @port_range = Array(ports).first.to_i..Array(ports).last.to_i end super end |
Instance Attribute Details
#egress ⇒ Boolean (readonly)
Returns True if this is an egress permission.
76 77 78 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 76 def egress @egress end |
#groups ⇒ Array (readonly)
Returns An array of security groups that have been granted access with this permission.
73 74 75 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 73 def groups @groups end |
#ip_ranges ⇒ Array (readonly)
Returns An array of string CIDR ip addresses.
69 70 71 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 69 def ip_ranges @ip_ranges end |
#port_range ⇒ Range (readonly)
Returns The port range (e.g. 80..80, 4000..4010, etc).
66 67 68 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 66 def port_range @port_range end |
#protocol ⇒ Symbol (readonly)
Returns The protocol (:tcp, :udp, :icmp).
63 64 65 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 63 def protocol @protocol end |
#security_group ⇒ SecurityGroup (readonly)
Returns The security group this permission is authorized for.
60 61 62 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 60 def security_group @security_group end |
Instance Method Details
#authorize ⇒ IpPermission
Authorizes this permission from its security group.
85 86 87 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 85 def update_sg(egress? ? :authorize_egress : :authorize_ingress) end |
#egress? ⇒ Boolean
Returns true if this is an egress permission.
79 80 81 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 79 def egress? @egress ? true : false end |
#eql?(other) ⇒ Boolean Also known as: ==
Returns true if the other IpPermission matches this one.
97 98 99 100 101 102 103 104 105 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 97 def eql? other other.is_a?(IpPermission) and other.security_group == security_group and other.protocol == protocol and other.port_range == port_range and other.ip_ranges.sort == ip_ranges.sort and other.groups.sort == groups.sort and other.egress? == egress? end |
#revoke ⇒ IpPermission
Revokes this permission from its security group.
91 92 93 |
# File 'lib/aws/ec2/security_group/ip_permission.rb', line 91 def revoke update_sg(egress? ? :revoke_egress : :revoke_ingress) end |