Class: CloudFormationTool::CLI::Create
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- CloudFormationTool::CLI::Create
- Defined in:
- lib/cloud_formation_tool/cli/create.rb
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/cloud_formation_tool/cli/create.rb', line 52 def execute name = stack_name || File.basename(File.dirname(File.(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) puts st.output end |
#get_params ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cloud_formation_tool/cli/create.rb', line 32 def get_params params = if param_file yaml = YAML.load(read_param_file 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 |
#read_param_file(file) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/cloud_formation_tool/cli/create.rb', line 22 def read_param_file(file) param_uri = URI(file) case param_uri.scheme when /^http/ Net::HTTP.get(param_uri) else File.read(file) end end |