Class: Admiral::Tasks::CloudFormation

Inherits:
Thor
  • Object
show all
Extended by:
Base
Includes:
Util::CloudFormation
Defined in:
lib/admiral-cloudformation/tasks.rb

Constant Summary collapse

EXAMPLES =
['elasticsearch', 'meteor', 'mongo']
NAME =
'cf'
USAGE =
'cf <command> <options>'
DESCRIPTION =
'Commands for wielding AWS CloudFormation templates.'

Constants included from Util::CloudFormation

Util::CloudFormation::DEFAULT_RECIPES, Util::CloudFormation::FAILED_STATS, Util::CloudFormation::SUCCESS_STATS

Instance Method Summary collapse

Methods included from Util::CloudFormation

#client, #create_stack, #name, #params, #stack_name, #update_stack

Instance Method Details

#createObject



29
30
31
32
# File 'lib/admiral-cloudformation/tasks.rb', line 29

def create
  template = File.read options[:template]
  create_stack stack_name(options[:environment]), template, params(options[:environment])
end

#destroyObject



45
46
47
# File 'lib/admiral-cloudformation/tasks.rb', line 45

def destroy
  super stack_name options[:environment]
end

#init(type) ⇒ Object

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
# File 'lib/admiral-cloudformation/tasks.rb', line 51

def init(type)
  raise ArgumentError, "#{type} must be one of #{EXAMPLES.join(',')}" unless EXAMPLES.include?(type)

  path = File.expand_path("../../../examples/#{type}", __FILE__)
  FileUtils.cp Dir.glob("#{path}/*"), Dir.getwd
  puts "[admiral] #{type} CloudFormation setup initialized."
end

#updateObject



37
38
39
40
# File 'lib/admiral-cloudformation/tasks.rb', line 37

def update
  template = File.read options[:template]
  update_stack stack_name(options[:environment]), template, params(options[:environment])
end