lib/kumogata/client.rb in kumogata-0.1.1 vs lib/kumogata/client.rb in kumogata-0.1.2

- old
+ new

@@ -55,10 +55,15 @@ def list(stack_name = nil) stacks = describe_stacks(stack_name) JSON.pretty_generate(stacks) end + def export(stack_name = nil) + template = export_template(stack_name) + devaluate_template(template).chomp + end + private ########################################################### def open_template(path_or_url) open(path_or_url) do |f| if ruby_template?(path_or_url) @@ -144,26 +149,10 @@ @__hash__[path] = value end end end - def describe_stacks(stack_name) - AWS.memoize do - stacks = @cloud_formation.stacks - stacks = stacks.select {|i| i.name == stack_name } if stack_name - - stacks.map do |stack| - { - 'StackName' => stack.name, - 'CreationTime' => stack.creation_time, - 'StackStatus' => stack.status, - 'Description' => stack.description, - } - end - end - end - def create_stack(template, stack_name) stack_name = stack_name || 'kumogata-' + UUIDTools::UUID.timestamp_create Kumogata.logger.info("Creating stack: #{stack_name}".cyan) stack = @cloud_formation.stacks.create(stack_name, template.to_json, build_create_options) @@ -225,9 +214,31 @@ errmsgs = ['Delete failed'] errmsgs << stack_name errmsgs << sstack.tatus_reason if stack.status_reason raise errmsgs.join(': ') end + end + + def describe_stacks(stack_name) + AWS.memoize do + stacks = @cloud_formation.stacks + stacks = stacks.select {|i| i.name == stack_name } if stack_name + + stacks.map do |stack| + { + 'StackName' => stack.name, + 'CreationTime' => stack.creation_time, + 'StackStatus' => stack.status, + 'Description' => stack.description, + } + end + end + end + + def export_template(stack_name) + stack = @cloud_formation.stacks[stack_name] + stack.status + JSON.parse(stack.template) end def while_in_progress(stack, complete_status) while stack.status =~ /_IN_PROGRESS\Z/ print '.'.intense_black unless @options.debug?