Class: Ironfan::Dsl::SecurityGroup

Inherits:
Ironfan::Dsl show all
Defined in:
lib/ironfan/dsl/security_group.rb

Instance Attribute Summary

Attributes included from Gorillib::Resolution

#underlay

Instance Method Summary collapse

Methods inherited from Ironfan::Dsl

#_skip_fields, #skip_fields, #to_manifest

Methods included from Gorillib::Resolution

#deep_resolve, #merge_resolve, #merge_values, #read_resolved_attribute, #read_set_attribute, #read_set_or_underlay_attribute, #read_underlay_attribute, #resolve, #resolve!, #resolve_value

Methods included from CookbookRequirements

#_cookbook_reqs, #children, #cookbook_req, #cookbook_reqs, #join_req

Methods inherited from Builder

ui, #ui

Instance Method Details

#authorize_group(other_name) ⇒ Object



45
46
47
48
49
# File 'lib/ironfan/dsl/security_group.rb', line 45

def authorize_group(other_name)
  group_authorized << other_name.to_s
  group_authorized.compact!
  group_authorized.uniq!
end

#authorize_port_range(range, cidr_ip = '0.0.0.0/0', ip_protocol = 'tcp') ⇒ Object



32
33
34
35
36
37
# File 'lib/ironfan/dsl/security_group.rb', line 32

def authorize_port_range(range, cidr_ip = '0.0.0.0/0', ip_protocol = 'tcp')
  range = (range .. range) if range.is_a?(Integer)
  range_authorizations << [range, cidr_ip, ip_protocol]
  range_authorizations.compact!
  range_authorizations.uniq!
end

#authorized_by_group(other_name) ⇒ Object



39
40
41
42
43
# File 'lib/ironfan/dsl/security_group.rb', line 39

def authorized_by_group(other_name)
  group_authorized_by << other_name.to_s
  group_authorized_by.compact!
  group_authorized_by.uniq!
end

#receive!(hsh, &blk) ⇒ Object

This allows Gorillib resolution to merge-resolve a collection of security groups and properly merge authorizations.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ironfan/dsl/security_group.rb', line 11

def receive!(hsh, &blk)
  if hsh.respond_to? :attributes
    hsh = hsh.attributes
  end
  super(hsh.merge({
        group_authorized: (
          group_authorized +
          hsh.delete(:group_authorized).to_a +
          hsh.delete('group_authorized').to_a).uniq,
        group_authorized_by: (
          group_authorized_by +
          hsh.delete(:group_authorized_by).to_a +
          hsh.delete('group_authorized_by').to_a).uniq,
        range_authorizations: (
          range_authorizations +
          hsh.delete(:range_authorizations).to_a +
          hsh.delete('range_authorizations').to_a).uniq,
      }),
      &blk)
end