class RenderCFN::MainStack

Public Class Methods

new( arguments) click to toggle source
Calls superclass method
# File lib/renderCFN/mainStack.rb, line 8
def initialize( arguments)
  
  super( arguments)
  
  @stackID = String.new()
  @templateName = 'main.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' => {} 
  }

end

Public Instance Methods

createStack() click to toggle source
# File lib/renderCFN/mainStack.rb, line 30
def createStack()
  uploadTemplate()
  cfn = Aws::CloudFormation::Client.new( )
  cfn.create_stack( stack_name: @@stackName, template_url: @templateURL, capabilities: ["CAPABILITY_IAM"])
  @@stackID = getAWSStackID()
end
deleteStack() click to toggle source
# File lib/renderCFN/mainStack.rb, line 43
def deleteStack()
  cfn = Aws::CloudFormation::Client.new( )
  cfn.delete_stack( stack_name: @@stackName)
end
execute() click to toggle source
# File lib/renderCFN/mainStack.rb, line 53
def execute()
  case @@action
  when 'create'
    createStack()
  when 'delete'
    deleteStack()
  when 'update'
    updateStack()
  when 'validate'
    validateStack()
  when 'print'
    render()
  end
end
getAWSStackID( ) click to toggle source
# File lib/renderCFN/mainStack.rb, line 24
def getAWSStackID( )
  cfn = Aws::CloudFormation::Client.new( )
  stackCall = cfn.describe_stacks(stack_name: @@stackName )
  stackCall['stacks'][0]['stack_id']
end
updateStack() click to toggle source
# File lib/renderCFN/mainStack.rb, line 37
def updateStack()
  uploadTemplate()
  cfn = Aws::CloudFormation::Client.new( )
  cfn.update_stack( stack_name: @@stackID, template_url: @templateURL, capabilities: ["CAPABILITY_IAM"] )
end
validateStack() click to toggle source
# File lib/renderCFN/mainStack.rb, line 48
def validateStack()
  cfn = Aws::CloudFormation::Client.new( )
  cfn.validate_template( template_url: @templateURL)
end