Class: CloudFormationTool::CLI::Create

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/cloud_formation_tool/cli/create.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



39
40
41
42
43
44
45
46
# File 'lib/cloud_formation_tool/cli/create.rb', line 39

def execute
  name = stack_name || File.basename(File.dirname(File.expand_path(file)))
  st = CloudFormation::Stack.new(name)
  log "Creating stack #{name}"
  start = Time.now
  log "Created " + st.create(file, get_params).to_s
  st.monitor(start)
end

#get_paramsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cloud_formation_tool/cli/create.rb', line 19

def get_params
  params = if param_file
    yaml = YAML.load(File.read(param_file)).to_h
    if param_key
      raise "Missing parameter section '#{param_key}' in '#{param_file}'!" unless yaml[param_key].is_a? Hash
      yaml[param_key]
    else
      yaml
    end
  else
    Hash.new
  end
  # allow param_list to override parameters from the param file
  param_list.inject(params) do |h, param|
    k,v = param.split /\s*[=:]\s*/
    h[k] = v
    h
  end
end