lib/sfn/command/destroy.rb in sfn-0.5.0 vs lib/sfn/command/destroy.rb in sfn-1.0.0
- old
+ new
@@ -27,11 +27,13 @@
ui.confirm "Destroy listed stack#{plural}?"
stacks.each do |stack_name|
stack = provider.connection.stacks.get(stack_name)
if(stack)
nested_stack_cleanup!(stack)
- stack.destroy
+ api_action!(:api_stack => stack) do
+ stack.destroy
+ end
ui.info "Destroy request complete for stack: #{ui.color(stack_name, :red)}"
else
ui.warn "Failed to locate requested stack: #{ui.color(stack_name, :bold)}"
end
end
@@ -40,16 +42,19 @@
poll_stack(stacks.first)
else
ui.error "Stack polling is not available when multiple stack deletion is requested!"
end
end
- ui.info " -> Destroyed SparkleFormation#{plural}: #{ui.color(stacks.join(', '), :bold, :red)}"
+ ui.info " -> Destroyed Cloud Formation#{plural}: #{ui.color(stacks.join(', '), :bold, :red)}"
end
# Cleanup persisted templates if nested stack resources are included
def nested_stack_cleanup!(stack)
+ stack.nested_stacks.each do |n_stack|
+ nested_stack_cleanup!(n_stack)
+ end
nest_stacks = stack.template.fetch('Resources', {}).values.find_all do |resource|
- resource['Type'] == 'AWS::CloudFormation::Stack'
+ resource['Type'] == stack.api.class.const_get(:RESOURCE_MAPPING).key(stack.class).to_s
end.each do |resource|
url = resource['Properties']['TemplateURL']
if(url)
_, bucket_name, path = URI.parse(url).path.split('/', 3)
bucket = provider.connection.api_for(:storage).buckets.get(bucket_name)