lib/cfer.rb in cfer-0.5.0 vs lib/cfer.rb in cfer-0.6.0
- old
+ new
@@ -83,15 +83,21 @@
puts "Caught interrupt. What would you like to do?"
case HighLine.new($stdin, $stderr).choose('Continue', 'Quit', 'Rollback')
when 'Continue'
retry
when 'Rollback'
+ rollback_opts = {
+ stack_name: stack_name
+ }
+
+ rollback_opts[:role_arn] = options[:role_arn] if options[:role_arn]
+
case operation
when :created
- cfn_stack.delete_stack stack_name: stack_name
+ cfn_stack.delete_stack rollback_opts
when :updated
- cfn_stack.cancel_update_stack stack_name: stack_name
+ cfn_stack.cancel_update_stack rollback_opts
end
retry
end
end
end
@@ -183,15 +189,26 @@
def delete!(stack_name, options = {})
config(options)
cfn = options[:aws_options] || {}
cfn_stack = options[:cfer_client] || cfn_stack = Cfer::Cfn::Client.new(cfn.merge(stack_name: stack_name))
- cfn_stack.delete_stack(stack_name: stack_name)
+ delete_opts = {
+ stack_name: stack_name
+ }
+ delete_opts[:role_arn] = options[:role_arn] if options[:role_arn]
+ cfn_stack.delete_stack(delete_opts)
+
if options[:follow]
tail! stack_name, options.merge(cfer_client: cfn_stack)
end
+ rescue Aws::CloudFormation::Errors::ValidationError => e
+ if e.message =~ /Stack .* does not exist/
+ raise Cfer::Util::StackDoesNotExistError, e.message
+ else
+ raise e
+ end
end
# Builds a Cfer::Core::Stack from a Ruby block
#
# @param options [Hash] The stack options
@@ -268,11 +285,11 @@
final_params
end
def render_json(obj, options = {})
if options[:pretty_print]
- puts JSON.pretty_generate(obj, options)
+ puts Cfer::Util::Json.format_json(obj)
else
puts obj.to_json
end
end
@@ -334,10 +351,11 @@
version.rb
block.rb
config.rb
util/error.rb
+util/json.rb
core/hooks.rb
core/client.rb
core/functions.rb
core/resource.rb
@@ -347,6 +365,5 @@
cfn/client.rb
}.each do |f|
require "#{File.dirname(__FILE__)}/cfer/#{f}"
end
Dir["#{File.dirname(__FILE__)}/cferext/**/*.rb"].each { |f| require(f) }
-