Class: Awsom::SecurityGroup

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/awsom/security_group.rb

Defined Under Namespace

Classes: DiffStruct

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger

#debug?, #logger, logger, #stderr, stderr

Constructor Details

#initialize(name, vpc_id:) ⇒ SecurityGroup

Returns a new instance of SecurityGroup.



16
17
18
19
# File 'lib/awsom/security_group.rb', line 16

def initialize(name, vpc_id:)
  @name = name
  @vpc_id = vpc_id
end

Class Method Details

.id(name, vpc_id) ⇒ Object



11
12
13
14
# File 'lib/awsom/security_group.rb', line 11

def self.id(name, vpc_id)
  sg = new(name, vpc_id: vpc_id)
  sg.id
end

Instance Method Details

#created(&block) ⇒ Object



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

def created(&block)
  @desired_rules = Set.new
  instance_eval &block
  @id = find_id || create
  sync
  @id
end

#description(description) ⇒ Object



27
28
29
# File 'lib/awsom/security_group.rb', line 27

def description(description)
  @description = description
end

#idObject

Raises:



21
22
23
24
25
# File 'lib/awsom/security_group.rb', line 21

def id
  id = find_id
  raise Error, "specified security_group #{@name} doesn't exist in vpc #{@vpc_id}" if not id
  id
end