Class: Skewer::AWS::SecurityGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/security_group.rb

Overview

Security group permissions for our AWS service.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, desc, ports) ⇒ SecurityGroup

Returns a new instance of SecurityGroup.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/aws/security_group.rb', line 7

def initialize(name, desc, ports)
  @service ||= SkewerConfig.get 'aws_service'
  groups = @service.security_groups
  group = groups.select { |group| group.name == name }[0]

  if group.nil? == true
    group = @service.create_security_group(name, desc)
    group = groups.get(name)
  end
  @group = group

  if ports.length >= 1
    ensure_port_ranges(group, ports)
  end
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



5
6
7
# File 'lib/aws/security_group.rb', line 5

def group
  @group
end

#serviceObject (readonly)

Returns the value of attribute service.



5
6
7
# File 'lib/aws/security_group.rb', line 5

def service
  @service
end

Instance Method Details

#ensure_port_ranges(group, ports) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/aws/security_group.rb', line 24

def ensure_port_ranges(group, ports)
  ports.each do |port|

    description = port[:description]
    range = port[:range]

    group.revoke_port_range(range)
    group.authorize_port_range(range, {:name => description})
    # TODO: get the port range options in there
  end
end