Class: AWS::EC2::SecurityGroup::EgressIpPermissionCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/aws/ec2/security_group/egress_ip_permission_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(security_group, options = {}) ⇒ EgressIpPermissionCollection

Returns a new instance of EgressIpPermissionCollection.



22
23
24
25
# File 'lib/aws/ec2/security_group/egress_ip_permission_collection.rb', line 22

def initialize security_group, options = {}
  @security_group = security_group
  super
end

Instance Attribute Details

#security_groupSecurityGroup (readonly)

Returns:



28
29
30
# File 'lib/aws/ec2/security_group/egress_ip_permission_collection.rb', line 28

def security_group
  @security_group
end

Instance Method Details

#eachObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/aws/ec2/security_group/egress_ip_permission_collection.rb', line 30

def each
  security_group.ip_permissions_list_egress.each do |p|

    # egress permissions don't always have ports
    if p[:from_port]
      ports = [p[:from_port], p[:to_port]]
    else
      ports = nil
    end

    ip_ranges = p.ip_ranges.collect{|ip| ip.cidr_ip }

    groups = p.groups.collect do |group|
      SecurityGroup.new(group[:group_id],
        :owner_id => group[:user_id],
        :vpc_id => security_group.vpc_id,
        :config => config)
    end

    permission = IpPermission.new(security_group, p.ip_protocol, ports,
      :ip_ranges => ip_ranges,
      :groups => groups,
      :egress => true,
      :config => config)

    yield(permission)

  end
end