Class: RenderCFN::NestedStack

Inherits:
Stack show all
Defined in:
lib/renderCFN/nestedStack.rb

Instance Method Summary collapse

Methods inherited from Stack

#add, #render, #uploadTemplate

Methods inherited from AwsObject

#get, #name

Constructor Details

#initialize(arguments) ⇒ NestedStack

Returns a new instance of NestedStack.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/renderCFN/nestedStack.rb', line 6

def initialize( arguments)
  
  @serviceTitle = arguments[:serviceTitle] or nil
  @serviceName = arguments[:serviceName] or nil
  @nestedStackName = "#{@serviceName}NestedStack"
  
  unless @serviceTitle and @serviceName then
    print "Please set serviceTitle and serviceName\n"
  end
  
  @stackID = String.new()
  @templateName = "#{@serviceName}.yml"
  @templateURL = "https://s3.amazonaws.com/#{@@bucket}/stacks/#{@@stackName}/#{@templateName}"
  
  @awsObject = { 
    'AWSTemplateFormatVersion' => '2010-09-09',
    'Description' => arguments[:description] ? "#{arguments[:description]} [renderCFN]" : 'Made with renderCFN',
    'Resources' => {} ,
    'Parameters' => {}
  }
  
  @nestedStackObject = {
    @nestedStackName => {
      'Type' => 'AWS::CloudFormation::Stack',
      'Properties' => {
        'TemplateURL' => @templateURL,
        'Parameters' => {}
      }
    }
  }
  
end

Instance Method Details

#addParameter(dependentObject, type) ⇒ Object



39
40
41
42
# File 'lib/renderCFN/nestedStack.rb', line 39

def addParameter( dependentObject, type)
  @awsObject['Parameters'].merge!( dependentObject => { 'Type' => type }  )
  @nestedStackObject[@nestedStackName]['Properties']['Parameters'].merge!( dependentObject => { 'Ref' => dependentObject } )
end

#getNestedStackObject



44
45
46
47
# File 'lib/renderCFN/nestedStack.rb', line 44

def getNestedStack()
  uploadTemplate()
  @nestedStackObject
end