Class: RenderCFN::Stack

Inherits:
AwsObject show all
Defined in:
lib/renderCFN/stack.rb

Direct Known Subclasses

MainStack, NestedStack

Instance Method Summary collapse

Methods inherited from AwsObject

#get, #name

Constructor Details

#initialize(arguments) ⇒ Stack

Returns a new instance of Stack.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/renderCFN/stack.rb', line 10

def initialize( arguments)
  
  super( arguments)
  @stackID = String.new()
  @templateName = 'main.yml'
  @templateURL = "https://s3.amazonaws.com/#{@@bucket}/stacks/#{@@stackName}/#{@templateName}"
  
  unless @@action then
    print "Must set action.\n"
  end
  
  unless @@stackType and @@environmentType and @@environmentName then 
    print "Must set arguments for to stack name.\n"
    exit 1
  end
  
  unless @@action == 'create' or @@action == 'print' then
    @@stackID = getAWSStackID()
  end
  
  @awsObject = Hash.new
  
end

Instance Method Details

#add(thing) ⇒ Object



38
39
40
# File 'lib/renderCFN/stack.rb', line 38

def add( thing)
  @awsObject['Resources'].merge!(thing)
end

#renderObject



34
35
36
# File 'lib/renderCFN/stack.rb', line 34

def render 
  YAML.dump(self.get)
end

#uploadTemplateObject



42
43
44
45
46
# File 'lib/renderCFN/stack.rb', line 42

def uploadTemplate( )
  s3 = Aws::S3::Resource.new(region:'us-east-1')
  obj = s3.bucket(@@bucket).object("stacks/#{@@stackName}/#{@templateName}")
  obj.put(body: render)
end